22

I'm trying to setup Wordpress to be able to install plugins via SFTP (SSH) on a Centos 6 VPS.

I've been able to modify wp-config so it uses the right credentials with user as my SFTP user.

Now I have a permission related problem, as if I do a chmod 777 on my wp-content folder I'm able to install, but with the normal permissions it can't create folders.

I'm using Nginx and all my wp-content files and folders are owned by user and I've tried setting the group to nginx but it doesn't work.

I also tried setting the user as nginx but still no luck.

UPDATE : I found out wordpress was using apache as user but I want to change this to my user instead. How can I do this ?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Geoffrey H
  • 1,280
  • 2
  • 10
  • 33
  • What is the output of ls -la for your plugins folder? – deb0rian Nov 01 '12 at 22:36
  • Everyting is owned by `user` with `nginx` group and rights `drwxr-xr-x`. But I've noticed one of the folder, the one for the plugin install I tried without `chmod 777` is set to `apache`. So I guess the user is `apache` then but this is not going to work. How can I change it ? – Geoffrey H Nov 01 '12 at 22:50
  • nginx , php-fpm , user and group and also file and folder permissions are answered in [here](http://stackoverflow.com/a/32727581/2977976) – Hassan Gilak Sep 22 '15 at 22:00

4 Answers4

31

On your production server, in your WordPress index.php file, at the top, you can temporarily put echo(exec("whoami"));die();

Then browse to your WordPress site and see what user was running. On Ubuntu, mine was www-data.

This was useful for me for: Can I install/update WordPress plugins without providing FTP access?

Community
  • 1
  • 1
Ryan
  • 22,332
  • 31
  • 176
  • 357
  • Same here. The user for apache on Debian was "www-data". – tedi Mar 03 '17 at 13:25
  • Dont know the reason but on browser exec function was returning null, had to execute the index.php file from cli then it returned the username. – f_i Mar 29 '18 at 06:27
3

The Wordpress user is also the web server user, so this should work:

ps -ef | grep http

or

ps -ef | grep apache

Tim Scollick
  • 1,242
  • 1
  • 16
  • 17
1

So it clearly says that a group has no W access.

You can do: chmod -R g+w /your/plugins/dir

And then, nginx group will be able to write there.

deb0rian
  • 966
  • 1
  • 13
  • 37
  • My bad I didn't even see this but it still won't create the folder. – Geoffrey H Nov 01 '12 at 23:05
  • Yes, also I've tried `chown -R apache` on my folder and now it works but I'd rather not have wordpress use `apache` but my `user` instead. How can I do this ? I'll update the question – Geoffrey H Nov 01 '12 at 23:17
  • You didn't said you have an apache there.. well. I think you can't, may a more experience linux user correct me. Also, worth trying to change nginx/apache configuration to run under your username, but then im not sure if it will not screw things up for the rest of the mechanism... but try it. – deb0rian Nov 01 '12 at 23:26
  • I don't. `apache` is probably the default username for Wordpress and that's why I want to change it. Although I guess it's better to let the web server run as its own user for security reasons. – Geoffrey H Nov 01 '12 at 23:35
1

Well it's not about /wp-content file permissions, so just leave the WordPress directory directory /wp-content permissions as 0755.

The fix that is required here has to be initiated within apache2.conf file; there we need to change "AllowOverride" directive for our /www/html/ directory from "AllowOverride None" to "AllowOverride All"

Follow the complete procedure here How to deal with GCP WordPress error "This page isn’t working example.com is currently unable to handle this request. HTTP ERROR 500

With this we tell a web server to allow a use of .htaccess file.

Zulkifl Agha
  • 175
  • 1
  • 12