Overview:
I have a dozen or so WP installs hosted on an Ubuntu 14.04 LTS, w/ PHP 5.5.9 & Nginx 1.4.6. MySQL runs on alternate node, not on public network.
Goal:
To have directories & files of each WP install NOT be world-readable. If a malicious user gets access to a particular WP install, I can't have them be able to navigate to an alternate WP install and read DB credentials.
Details:
Nginx runs as www-data. A user, with no shell, is created for each vhost. Each vhost supports a single WP install. PHP-FPM pools run specific to each user / vhost. PHP-FPM pools connect w/ Nginx via socks, not the loopback IP.
Reading the following Wordfence article, I have attempted to set file permissions as follows:
Files - 640
Directories - 750
When I configure permissions as such, Nginx, running as www-data, can no longer correctly access the WP files. If I set permissions back to 644 & 755, everything works as expected.
Sites are installed in the following structure:
/var/www/site1.com/public
/var/www/site2.com/public
/var/www/site3.com/public
and so on.
Each directory is owned by the corresponding user & user group. ie:
site1-com:site1-com /var/www/site1.com
We've had a WP site get hacked, and they were able to get a php file manager script onto the server. My understanding is that this script is being run by user www-data. (Checked w/ ps aux
) If that's true, that I suspect the malicious user could access all other WP installs via their php file manager script.
How can I improve my permission setup to harden security? I'm open to all suggestions, even if it means re-configuring the entire stack install.
Thanks in advance.