I am running a web server on Nginx 1.14.0 (Ubuntu 18.04, php-fpm 7.1.25) on my SSD system drive (/dev/sda5, ext4) and everything works just fine.
And I tried to move my web-server dir to another HDD (/dev/sdb1, ext4) in my computer to free up some space on my SSD. So I copied /var/www/html directory to /media/myhdd/newhtml and preserved the owner and permissions of the original directory. All was copied OK.
And when I try to open web server from new dir (/media/myhdd/newhtml), I get 403 Forbidden (nginx error log: 13: Permission denied) error.
I checked permissions for my new dir and restarted nginx a hundred times already. Permissions are the same as my /var/www/html dir and are set to 755 recursively.
chown -R myusername:www-data /media/myhdd/newhtml chmod -R 755 /media/myhdd/newhtml
I even tried to simplify things and output directory listing.
This works and outputs directory listing, as expected:
server {
listen 80;
listen [::]:80;
root /var/www/html;
autoindex on;
server_name localhost;
charset UTF-8;
}
this DOES NOT WORK, and gives FORBIDDEN 403 error:
server {
listen 80;
listen [::]:80;
root /media/myhdd/newhtml;
autoindex on;
server_name localhost;
charset UTF-8;
}
since permissions for both directories are the same, I expect nginx to list dirs from /media/myhdd/newhtml, as it does for /var/www/html
please share your ideas about what might cause this unexpected result? Thanks.