@vistacali
The user that NGINX is running as must be able to access the directories its attempting to read and/or write to. In most cases, NGINX is either running as the user nginx
or www-data
.
We can check for the user
directive in /etc/nginx/nginx.conf
by running:
grep user /etc/nginx/nginx.conf
If the return of that command spits out a user, we can then change the ownership of the directories you’ve mentioned using chown
.
chown -R user:group /insert/path/here
So if NGINX is running as www-data
:
chown -R www-data:www-data /insert/path/here
If the grep
command doesn’t spit out a user, we can always see who owns NGINX’s directories and we should be able to use that user.
Simply run:
ls -al /etc/nginx
and grab the user from the output.
As a side note, things are a bit different if you happen to be running PHP-FPM with NGINX. In that case, the directories and files should be owned by the user that the PHP-FPM process is running as.
If you are running PHP-FPM, you can cd
in to the main directory and check the pool file. If you’ve not modified anything there for your setup, the default user for PHP-FPM is always www-data
, so that should be the user who owns all files and directories.
cd /etc/php/*/fpm/pool.d/
and then:
nano www.conf