Cpanel + Apache + Wordpress user permissions

5

1

I am on Cpanel. I have root access.

When I create a new domain, a new user is created. Let's call it example.com with the user name being example. This will create:

/home/example/www/

For WP to work here, it requires the same access as apache. So I usually, for updating etc, need to give "nobody" user access.

However, for FTP etc to work normally, I need files and folders to be owned by the user (example in my case).

What do people recommend. Should I add example to the nobody group? Or what else?

This is driving me up the wall.

Thanks!

PKHunter

Posted 2012-08-05T12:49:12.753

Reputation: 193

Answers

3

By default, new installs of cPanel run PHP under the SuPHP loader, which cause PHP scripts to be run as their user owner instead of the nobody user. Under this scheme the proper way to setup Wordpress (and other PHP scripts/apps) is to set the ownership to all files/directories to the cPanel user and group. Access permissions should be set to 0644 for files and 0755 for directories. Under SuPHP, you will receive a 500 error should these not be set properly, so you will know right away.

Under this setup the added benefit is that the files are always accessible to the cPanel user by FTP/File Manager.

You can check if you are currently running SuPHP in the WHM under Apache Configuration -> Configure PHP and SuExec or using the script:

/usr/local/cpanel/bin/rebuild_phpconf --current

If you aren't, and SuPHP support isn't built on the server, you can enable it by using the EasyApache build wizard from the WHM or /scripts/easyapache from a root shell.

Garrett

Posted 2012-08-05T12:49:12.753

Reputation: 4 039

2Had same problem and answer above helped a lot. Thanks! – JackTheKnife – 2016-02-11T20:55:14.373

@PKHunter didn't work for me... it was like this before and even with 777 permissions WP would ask FTP credentials. Just worked with nobody:nobody... – Ricardo BRGWeb – 2017-09-07T22:49:15.520

Thanks Garrett. For someone else in the future, here is what I discovered. The following works:

chown -R example:nobody /home/example/www/ – PKHunter – 2012-09-16T12:53:18.460