@Vanker
The way the repository packages are setup, files in:
/etc/nginx/sites-available
are symlinked to:
/etc/nginx/sites-enabled
i.e
/etc/nginx/sites-available/default => /etc/nginx/sites-enabled/default
The NGINX configuration file located at /etc/nginx/nginx.conf
then loads the files from:
/etc/nginx/sites-enabled
You can confirm this by looking at the bottom of the http
block for a line that shows:
include /etc/nginx/sites-enabled/*
It may also look like:
include sites-enabled/*
Changes should reflect regardless of whether you modify the link or the actual file.
…
Changes to the web root that NGINX uses are reflected by modifying root
in the server block. If it’s current using /var/www/html
, i.e.
root /var/www/html;
You’d simply change that line and reload/restart NGINX.
…
That being said, you may find it more beneficial to clean up the server block and remove the clutter so that you’re not sifting through commented lines that have no bearing on your configuration.
The server block you posted would look like the following, once cleaned up:
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I removed try_files $uri /index.php =404;
from the location ~ \.php$
block as it really shouldn’t be needed.
I also changed $query_string
to $args
as it’s more commonly used.
That said, you may need the index
line if it’s not defined in nginx.conf
, so we can add that back line so:
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
…
That being said, the one-click images are meant to be a starting point. You still need to know how to manage a server, setup the server, etc. Server/System administration, much like coding, isn’t a one-time deal that requires no further setup, configuration, or tweaking/tuning – it’s on-going.