Change document root in nginx for external drive

I have a scenario in which I use Windows and Ubuntu on the same machine, and I want my sites to be shared across the OS. I have created a directory called 'common-sites' on my D drive, and I have configured the Drupal site with the domain drupal-demo-8.com.

My Ubuntu has an nginx web server. I want my common-sites to be available for Ubuntu as well.

Approach

  • First login into the Ubuntu machine.
  • Mount D: drive with /media/window, using the below commands:

This will list all available partitions as follows:

sudo fdisk -l
  /dev/sda1
  /dev/sda2
  ...
sudo mkdir /media/windows
sudo mount -t ntfs -o nls=utf8,umask=0222 /dev/sda1 /media/win

Now change the docroot in the nginx site's configuration-for example, my config is "drupal-demo-8.conf", which contains:

server {
  listen 80;
  server_name drupal-demo-8.com;
  root /var/www/drupal-demo-8.com/docroot;
  index index.php;
  # For Drupal >= 7 clean url
  location / {
    try_files $uri /index.php?$query_string;
  }
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  }
}

Change the docroot to /media/windows/common-sites/drupal-demo-8.com/docroot and restart nginx.

0/5