I just setup a VPS and I installed everything I needed and it runs well. Problem is that I want it to be able to update automatically and allow me to install plugins without ftp. This is my setup:

  1. I created a new user and group named: "wordpress"
  2. Nginx and PHP-FPM both uses "wordpress" as the user and group.
  3. I added my own ssh account to the group "wordpress". Lets say my username is "user".
  4. I changed the ownership of the files to the user "user" and the group "wordpress" including the right permissions (775 for folders and 664 for files, I will try 755/644 later).
  5. Changed folder group (chgrp -R) to "wordpress". I also performed "chmod g+s" on the folder so new files belong to the "wordpress" group.

With all of the above I still can't install new plugin (and probably themes or update), but if I change the files owner to "wordpress" all is fine. Is it not possible to have the "user" own the files so incase I upload my files with sftp I don't have to chown.

Is it possible to have WordPress files owned by a user thats in the same group as the group that runs nginx/php-fpm and still be able to install plugins?

More info:
nginx.conf at the top contains user wordpress wordpress and pool.d/www.conf contains 2 lines with user = ilyesnl group = ilyesnl. I also confirmed both processes being run by user wordpress.

  • There is a related post here: wordpress.stackexchange.com/a/96454/21376 – s_ha_dum May 14 '14 at 17:44
  • Although I have done exactly the same. I did everything again fallowing your guide on the letter. Restarted the services, but still no succes. I just confirmed that nginx and php-fpm are running with user "wordpress". id wordpress and id user show uid=1000(user) gid=1000(user) groups=1000(user),1001(wordpress) and uid=107(wordprss) gid=1001(wordpress) groups=1001(wordpress). So I am not sure what is going wrong. Checking php.ini I cant find safe_mode at all except for sql.safe_mode (so not related). – Ilyes512 May 14 '14 at 18:13

WordPress specifically checks that the fileowner of the files it creates are identical to the value returned by getmyuid.

Meaning that if it creates files using a different owner than the owner of the WordPress files themselves, it won't use the "direct" mode.

Same group is not enough. The files WordPress writes must have the same ownership as the WordPress files themselves, or it won't do it and will instead try other methods, such as FTP permissions. Meaning that the PHP process must be running as the same user that actually owns the WordPress files.

So if your PHP is running as "wordpress" but the files are owned by "user", then you get the FTP stuff instead.

The test for this is in the get_filesystem_method() function.

  • So I think I will just create an account for every nginx server block and add that user to the "wordpress" group. That way I can ftp without any problems then. Will have to check how I will do the same with a git deploy strategy, but thats a problem for later. Thanks! – Ilyes512 May 14 '14 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.