vistacali
By:
vistacali

error 404 Not Found to symlink

January 20, 2017 609 views
Fedora Nginx

created a symlink like this

from Hdd To SSD

ln -s /run/media/alireza/hdd/public_html/ .

error log :

2017/01/20 05:29:22 [crit] 19206#0: *1 stat() "/home/alireza/public_html/" failed (13: Permission denied), client: 127.0.0.1, server: abc.dev, request: "GET / HTTP/1.1", host: "abc.dev"
1 Answer

@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
Have another answer? Share your knowledge.