According to: http://codex.wordpress.org/Changing_File_Permissions
[pullquote]All files should be owned by your user account on your web server, and should be writable by your username. Any file that needs write access from WordPress should be group-owned by the user account used by the webserver.[/pullquote]
Related information: http://codex.wordpress.org/Updating_WordPress#Automatic_Update
On plesk, “your user account” is set in the admin interface (Domain>web hosting setup>Ftp user). The webserver user account is apache and the standard group of which apache is member is psaserv. Unfortunately, plesk’s default setup configures the ftp server to upload files as the correct user but as group “psacln” and does not give the group write permissions to the files. Here is a quick fix to correct this behavior. (You will need root access to do these changes).
1- Edit /etc/proftpd.confand change line “Umask 022” to:
Umask 002
This will give write access to the psacln group when new files are uploaded via FTP.
2- Add the webserver account to the psacln group by editing /etc/group. Change line “psacln:x:2522:” to:
psacln:x:2522:apache
Just add apache to the end of the line. 2522 is the group ID and will differ on each server,
leave yours as is. If there is already a username after the last “:”, add a comma and then apache (psacln:x:2522:user1,apache). You could refer here if you want more info on the group file structure.
3- Make sure php safe mode is OFF. In plesk admin “domain>web hosting setup>php support”, “PHP ‘safe_mode’ on” must be unchecked. WordPress does not require PHP to be in safe-mode, Plesk does because the webserver runs as user apache and the files ca be uploaded/updated either as the ftp user (updates) or as apache (media additions). Plesk’s application Vault lists safe mode off as one of WordPress’s requirements.
4- Reload apache:
service httpd restart
Done
To fix an already installed wordpress which was uploaded before these changes were made, follow these steps:
cd /var/www/vhosts/yourdomain.com chown -R youruser:psacln httpdocs chmod -R g+w httpdocs/wp-content find httpdocs -type d -exec chmod g+s {} \;
The last part (chmod g+s) sets the “s” flag to all directories. This is necessary so any folders or files created within these directories will have the folder’s group owner.
Don’t know if this instruction is up to date but when I tried to follow it, it caused my existing wp installation to go bonkers, since I’m running a wp-e-commerce plugin, this broke all the thumbnail paths also any attached image belonging to /wp-content/uploads/year/date/ also were not viewable to the public primarily due to the permission settings you suggested above in step 2. When i manually changed the wp-content/uploads directory to 0755 things started to reappear. Had to manually change the items in the database to get wp-e-commerce thumbnail path to right directory (this might be unrelated though). So just out of curiosity why 2522? also, what happens when you don’t have that existing line to begin with and as u said from
“psacln:x:2522:” to “psacln:x:2522:apache”
but I have psacln:x:505: to begin with.?
Hi Tony, I’m sorry to hear the procedure caused some trouble on your website. From what you say, it was probably due to the modification on the /etc/group file. The 2522 in my instructions refer to the group id on my server, yours was 505 and should have been left as is. I updated the instructions based on your feedback. Hopefully the procedure is more clear now and your experience will benefit others.
Thankyou so much for this post Ryan!
For the last week I’ve been in a constant support ticket debate with my new VPS provider because I was having file permissions issues and they couldn’t fix it for me even though I pointed them to the Codex article that you linked to as well.
I just SSHed into our VPS and followed this post and it’s fixed everything. You Sir are a freaking champion.
I’ve a WordPress web designer/developer and know stuff all about SSH and would’ve never have been able to fix my permissions error with Plesk without this post. I’m gonna link my host to this post.
To be honest I’m concerned that they couldn’t fix this for us seeing we’re paying for a ‘managed VPS’!
Thanks again. You’ve made my day! 🙂
Great! I’m glad this helped you! Don’t be too hard on your hosting provider, there is so much to know about hosting. Nobody can have complete knowledge about everything but I understand that when you pay for a service, you ask for something in return.
Btw, nice website you have there. Looks like you are in the business. I also do websites using WordPress as a CMS, I have evaluated many different CMS plateforms over the past years (Drupal, PHPNuke, Joomla!, eZ Publish, XOOPS, Midgard) and although I can’t nail it down to a specific reason, WordPress just feels better. I also do website and VPS hosting (unmanaged, managed or/and hi-availability – 99.99% uptime) for a decent price if you care.
“Make sure php is not in safe mode”
WordPress makes it pretty clear that you don’t need safemode on to run wordpress. That being said (using another workaround) I was able to get it to work (changing permissions etc.) by turning safemode on similar to what you have suggested. But having safemode on with multiple users has security risks. Any workaround that doesn’t involve turning safemode on? And is this a plesk or a wp issue?
Hi Larry, as PHP 5.3 now officially depreciated safe_mode, I guess we’ll have to find another way to work around this problem…
I am aware that WordPress’s documentation say there is no problem with enabling PHP safe_mode but here is the where I understand the problem occurs.
When safe mode is on, PHP will only allow writing to a file or folder if the user is the OWNER. Yes, you get this, regular file permissions don’t matter here, safe_mode on allows writing only for OWNERS! Beeing in the same group and having the correct write permissions is not enough. Also, newly created folders inherit the permissions of the domain user account, not the user the webserver is running under.
One other thing. I also got media uploads to work by manually creating the “uploads” directory and changing the permissions to 777 doing nothing else. Do you agree having uploads set to 777 is safer then having safe mode “on”?
Thanks, this solved my problem.
Hats off Ryan!!!! You are simple the best!! I have been struggling with this error for a while. Even contact Plesk guys and my hosting to solve but they couldn’t help either. Really glad I found this post. Do you have a page somewhere so I can follow you??
Thanks
Thank you, I am glad it helped you.
To subscribe, feel free to enter your email in the “SUBSCRIBE TO BLOG VIA EMAIL” section on the homepage. However, please be aware that I don’t post on a regular basis.