I created a symbolic link path in nginx server side which reference to my documents directory.
[user1@localhost ~]$ groups http // -> nginx user
user1 http
[user1@localhost nginx] sudo ln -s ~/Documents/nginx-sites/app /user/share/nginx/app
[user1@localhost nginx] ls
lrwxrwxrwx 1 root root 37 Sep 21 14:58 app -> /home/user1/Documents/nginx-sites/app
[user1@localhost nginx] ls -l ~/Documents/nginx-sites/app
drwxr-xr-x 7 user1 user1 4096 Sep 20 21:19 app
-rwxr-xr-x 1 user1 user1 1686 Sep 20 21:19 artisan
drwxr-xr-x 3 user1 user1 4096 Sep 20 21:19 bootstrap
drwxr-xr-x 2 maxtt maxtt 4096 Sep 20 21:19 public
...
[user1@localhost nginx] cat /etc/nginx/nginx.conf
server {
listen [::]:80;
server_name localhost;
root /usr/share/nginx;
index index.html index.htm index.php;
#access_log logs/host.access.log main;
location ~ \.php$ {
try_files $fastcgi_script_name =404;
#default fastcgi_params
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
}
However, nginx user seem like unable to access that files (permission denied). Nginx log file as below:
2022/09/21 13:35:20 [error] 20547#20547: *3 open() "/usr/share/nginx/app/public" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET /app/public HTTP/1.1", host: "localhost"
How can i get rid issue above, I had been add http user into user1 group, all directory have read and execute permission, but still fails. Is something wrong with my configuration ?
Here's the following that I tried, hope it show some tips to tell more
[user1@localhost nginx]$ sudo -u http stat app/public
stat: cannot statx 'app/public': Permission denied
[user1@localhost nginx]$ sudo -u http stat app
File: app -> /home/user1/Documents/nginx-sites/app
Size: 37 Blocks: 0 IO Block: 4096 symbolic link
Device: 259,2 Inode: 13375664 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
...
[user1@localhost nginx]$ cd app
[user1@localhost app]$ sudo -u http stat public
File: public
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 259,2 Inode: 11015535 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 1001/ user1) Gid: ( 1002/ user1)
...