You are not logged in.

#1 2023-10-19 17:19:47

loranto
Member
Registered: 2022-11-02
Posts: 13

NGINX - Fix permission of /var/www into different partition

Hello. I'm tried to put www folder into different hard disk for use it with Nginx server.

Actual directory /var/www
New directory /mnt/tempDisk/www

tempDisk is an HDD format by NTFS

So:

$ sudo mv /var/www /mnt/tempDisk/
$ sudo  ln -s /mnt/tempDisk/www /var/

But now if I visit a page I get "file not found":

$ cat /var/log/nginx/sample.test-error.log 
2023/10/19 19:09:05 [error] 6722#6722: *7 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: sample.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "sample.test"
$ cat /etc/nginx/sites-available/sample 
server {
    listen 80;
    #listen 443 ssl http2;
    server_name .sample.test;
    root "/var/www/sample/";
    index index.html index.htm index.php;

    charset utf-8;
    client_max_body_size 512M;


    location / {
        try_files $uri $uri/ /index.php?$query_string;

    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log off;
    error_log /var/log/nginx/sample.test-error.log error;

    sendfile off;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }

    #ssl_certificate /etc/nginx/ssl/sample.test.crt;
    #ssl_certificate_key /etc/nginx/ssl/sample.test.key;
}
$ ls /var/ | grep www
lrwxrwxrwx  1 root root    17 Oct 19 19:04 www -> /mnt/tempDisk/www
$ sudo chown -R lorenzo:http /var/www
$ ls /var/ | grep www
lrwxrwxrwx  1 lorenzo http    17 Oct 19 19:04 www -> /mnt/tempDisk/www
$ sudo chown -R lorenzo:http sample/
$ ls | grep sample
drwxr-x--- 1 lorenzo lorenzo 4.0K Oct 19 19:03 sample

$ sudo chown -R lorenzo:http /mnt/tempDisk/www/sample
$ ls /mnt/tempDisk/www/ | grep sample
drwxr-x--- 1 lorenzo lorenzo 4.0K Oct 19 19:03 sample
$ whoami
lorenzo

$ cat /etc/nginx/nginx.conf | grep user
user http http;

$ cat /etc/hosts | grep sample.test
127.0.0.1       sample.test

Offline

#2 2023-10-19 17:26:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: NGINX - Fix permission of /var/www into different partition

Okay ... and why are you using a symlink?  If you want to serve content from /mnt/tempDisk/www just do that.  I'm not sure if NTFS itself will cause permission issues, but I am sure that the symlink isn't helping you any.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-10-19 20:22:25

loranto
Member
Registered: 2022-11-02
Posts: 13

Re: NGINX - Fix permission of /var/www into different partition

Trilby wrote:

Okay ... and why are you using a symlink?  If you want to serve content from /mnt/tempDisk/www just do that.  I'm not sure if NTFS itself will cause permission issues, but I am sure that the symlink isn't helping you any.

Ok I remove the symlink and fix nginx conf but I still have the same problem.

I can't change permission... NTFS trouble?

$ sudo chown -R lorenzo:http /mnt/tempDisk/www/sample
$ ls /mnt/tempDisk/www/ | grep sample
drwxr-x--- 1 lorenzo lorenzo 4.0K Oct 19 19:03 sample

Offline

#4 2023-10-20 16:54:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: NGINX - Fix permission of /var/www into different partition

Thanks - how are you mounting the ntfs partition?  What's the output of `mount`?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2023-10-20 17:57:51

loranto
Member
Registered: 2022-11-02
Posts: 13

Re: NGINX - Fix permission of /var/www into different partition

"I solved it" by formatting in ext4.

Offline

Board footer

Powered by FluxBB