Manual :: Installation ::
File Permissions
Link: http://manual.b2evolution.net/Directory_and_file_permissions
[NL]
This page applies to b2evo 0.9
When you upload files to your webserver by FTP, those files are saved on the server with some specific access permissions. Typically, everyone will be able to "read" the files and subdirectories, that is view them through the webserver, but only you and you alone (when you log into the FTP server) will be able to "write' to these files/subdirectories and modify them.
For some specific actions, b2evolution will need to modify some of its files. b2evo will also need to write new files when you use b2evo to upload an image or generate a static .html file. The problem is: b2evo is not you. More specifically: the PHP process that runs b2evo is not you!
Thus you will most likely need to change the permissions on some files and subdirectories in order to allow b2evo to write there and perform the requested actions.
Note: on somehosts, the default permissions already allow your scripts (b2evo in this cse) to change your files on your account. So you can try b2evo without changing any file permission and come back here only if you get a file permission error.
Most webservers runs some variant of UNIX. On these systems, file permissions can be changed via chmod. If you're not familiar with UNIX file permissions and chmod, check out A quick and dirty chmod Tutorial. If your server is running Windows you probably don't need to change anything.
You can change permissions on files/folder either with an FTP client program (like Filezilla), a Unix shell or a web file manager like the one built into cPanel.
What files/subdirectories do need specific permissions?
Let's assume your b2evo is installed under /blogs. Here's what you need to change:
- chmod 666 /blogs/conf/_config.php if you want the installer to be able to automatically update your config based on your input.
- chmod 777 /blogs to allow creation of blog stub files from the admin interface or to generate static pages for your blogs.
- chmod 777 /blogs/media in order to upload images and other media from b2evo's backoffice.
- chmod 666 /blogs/skins/custom/* if you want to use the template editor for the custom skin.
18 comments
I can manually chmod the permission for the image file and all is ok then.
Where is the fix for this? I am not afraid of modifying the upload php file just need to know what and where to make the mod.
BTW I did chmod the files and folders with php files to 755 and the media folder to 777 but still the individual uploads end up set to 700.
Alan
What is the file that needs the chmod?
Thanks
Thanks
Nico
File cannot be written!
You should check the file permissions for [/iSERVER/Cluster/k/kumeir.com/www.kumeir/b.html]. See online manual on file permissions.
WHY? Are you tell me?
Thanks
kumeir
The image upload does not give read permissions!! The result is that the image file can't be seen in the posts.
I can manually chmod the permission for the image file and all is ok then.
Where is the fix for this? I am not afraid of modifying the upload php file just need to know what and where to make the mod.
BTW I did chmod the files and folders with php files to 755 and the media folder to 777 but still the individual uploads end up set to 700.
Alan
Thanks
Hi, I think I figured out code wise how to correct the default CHMOD of 600 to be what ever you want. You have to modify your "b2_upload.php" file.
Starting at line 144:
Change this:
=======================================================================
if (!strlen($imgalt)) {
move_uploaded_file($img1, $pathtofile) //Path to your images directory, chmod the dir to 777
or die( T_('Couldn\'t upload your file to:').' '.$pathtofile);
} else {
rename($img1, $pathtofile)
or die( T_('Couldn\'t upload your file to:').' '.$pathtofile);
}
==========================================================================
To This:
Note: I'm new to PHP, so I'm assuming this is OK. Note the 0644 is the
actual CHMOD value to be set. Hope this saves some hair :)
==========================================================================
if (!strlen($imgalt)) {
if (move_uploaded_file($img1, $pathtofile)) //Path to your images directory, chmod the dir to 777
{
// Read and write for owner, read for everybody else
// echo($pathtofile); debug purposes
chmod($pathtofile, 0644);
}
else
{
die( T_('Couldn\'t upload your file to:').' '.$pathtofile);
}
} else {
rename($img1, $pathtofile)
or die( T_('Couldn\'t upload your file to:').' '.$pathtofile);
====================================================
Regards,
Curt
Faribault Minnesota
Sorry, should of been more clear. The above code is to fix the non-viewable images after you've uploaded them in your blog. By default, the CHMOD value is "600" so they are not viewable. The code I placed above, CHMODs the image to 644 if successfully uploaded so that it can be viewed by default.
Hope this helps!
Curt
Faribault Minnesota
Any ideas?
I have an php upload script, that have been working on another webhotel. On a new webhotel it just could not work - and I spend numberous hours pulling my hair.
Then I found out that only owner had access on uploaded pictures - ok, that was the reason other uses could not se the pictures!!
Then more hours went, cause I could not find any info about how to set there permissions on-the-fly, when i was uploading! After pulling more hair, and almost giving up, I made one last google search and found this site and the saving statement:
chmod($upload_dir.$filename, 0644);
I am now a happy man - again :)
Thanks a lot for this information!!!
/thomas, Denmark
Running out of hair....