title: How to change nginx document root to point a folder placed in different partition in ubuntu 20.10?
body: <p>To change nginx document root I took below step:</p>
  <p>file: /etc/nginx/sites-available/default</p>
  <pre><code># root /var/www/html # commented this line
  root /media/{user}/DATA/www # this change give &quot; 404 not found &quot; when i visit '127.0.0.1'
  root /home/{user}/www # this works fine when i visit '127.0.0.1'
  </code></pre>
  <p>so, when I change document root to a folder placed in different partition it gives me &quot; 404 not found &quot;</p>
  <p>is there any other thing that i have to change, to point document root to a folder placed in different partition?</p>
  <p>whole file: /etc/nginx/sites-available/default</p>
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
      # SSL configuration
      #
      # listen 443 ssl default_server;
      # listen [::]:443 ssl default_server;
      #
      # Note: You should disable gzip for SSL traffic.
      # See: https://bugs.debian.org/773332
      #
      # Read up on ssl_ciphers to ensure a secure configuration.
      # See: https://bugs.debian.org/765782
      #
      # Self signed certs generated by the ssl-cert package
      # Don't use them in a production server!
      #
      # include snippets/snakeoil.conf;
  
      # root /var/www/html;
      root /home/sndp/www;
  
      # Add index.php to the list if you are using PHP
      index index.php index.html index.htm index.nginx-debian.html;
  
      server_name _;
  
      location / {
          # First attempt to serve request as file, then
          # as directory, then fall back to displaying a 404.
          try_files $uri $uri/ =404;
      }
  
      # pass PHP scripts to FastCGI server
      #
      location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          # With php-fpm (or other unix sockets):
          fastcgi_pass unix:/run/php/php8.0-fpm.sock;
          # With php-cgi (or other tcp sockets):
      #   fastcgi_pass 127.0.0.1:9000;
      }
  
      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      location ~ /\.ht {
          deny all;
      }
  }
  
  
  # Virtual Host configuration for example.com
  #
  # You can move that to a different file under sites-available/ and symlink that
  # to sites-enabled/ to enable it.
  #
  #server {
  #   listen 80;
  #   listen [::]:80;
  #
  #   server_name example.com;
  #
  #   root /var/www/example.com;
  #   index index.html;
  #
  #   location / {
  #       try_files $uri $uri/ =404;
  #   }
  #}
  </code></pre>
  <p>Edit:</p>
  <p>when I check error log there is an error:</p>
  <pre><code>2021/03/14 15:58:17 [crit] 24648#24648: *1 stat() &quot;/media/sndp/DATA/www/&quot; failed (13: Permission denied), client: ::1, server: _, request: &quot;GET / HTTP/1.1&quot;, host: &quot;localhost&quot;
  </code></pre>
  <p>but permissions are same for both of directories.</p>
  <p>Permissions:</p>
  <pre><code>❯ ls -al /home/sndp/www/
  drwxrwxr-x  5 sndp     sndp         4096 Mar 14 15:32 .
  drwxr-xr-x 25 sndp     sndp         4096 Mar 13 12:39 ..
  -rwxr-xr-x  1 www-data www-data       17 Mar 13 13:47 index.php
  
  ❯ ls -al /media/sndp/DATA/www/
  drwxrwxr-x 2 sndp     sndp     4096 Mar 14 15:57 .
  drwxrwxr-x 8 sndp     sndp     4096 Mar 14 15:57 ..
  -rwxr-xr-x 1 www-data www-data   17 Mar 13 13:47 index.php
  </code></pre>