0

To use the Nginx default conf (sites-available/default) one needs to uncomment all relevant lines in that file.

To avoid manual uncommenting each time I install a new server environment on a new machine, what I did was to make myself a copy of the uncommented default conf, and each time I just paste it, or redirect it (>), to the new default conf file, in the new machine.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}

The problem is that the above conf could change any day and if it changes tomorrow, it might mismatch a new Nginx I've installed with sudo apt-get install nginx on some machine.

Hence, I'm looking for a way to better cope with my need to turn on the default Nginx conf. I don't want to turn it on by manual uncommenting, or copy-paste a ready, uncommented version as I do now:

I aspire to turn on the default conf in a more safe way, maybe by some CLI command.

What will be a plausible way to do so?

1 Answers1

-2

You can define the configuration file with the "-c" option. Add the following line to /etc/default/nginx :

DAEMON_OPTS="-c  /thisismy.conf"

But I don't think an upgrade would overwrite your configurations changes without your permission.