I stumbled upon something odd (for me at least) when using CloudLinux for the first time. I'm a long time Ubuntu user, I would still consider myself novice, though.
I've installed Nginx with PHP-FPM on Ubuntu servers a multitude of times. My usual approach is to setup a user and create a www
directory in the user's home directory. I'd setup the PHP-FPM pool configuration user and group to the newly created user and point a Nginx VirtualHost to the users home directory with the document root pointing to that www
folder somewhere.
This has worked fine for me on Ubuntu for a long, long time.
Last week, tried setting up the same on CloudLinux (which to my understanding is a CentOS distrobution of some sort).
The result was quite different. I had no issues having Nginx execute PHP files, but I found that Nginx couldn't serve static (or other files, not handled by PHP-FPM). Fast forward some debugging, it became apparent that the nginx
user didn't have sufficient permission to read the /home/user/www
folder. The quick fix for me was to move the www
to /var/www/sitename
, update the document root in Nginx and I could be on my way.
This just made me think about what the actual difference was. Is my approach on Ubuntu even sane (ie. secure) when this didn't work on another distro?
Why can the Nginx user, without problems, read the contents of my user's home directory on Ubuntu, but not on CloudLinux?