I installed nginx/1.22.1
on debian 12 and it serves the default configuration by calling in the browser. If I created a custom configuration and removed the /etc/nginx/sites-enabled/default
, then the browser throws “unable to connect”. How to serve custom site using own configuration?
The steps I followed:
$ mkdir -p /var/www/<my-domain>/html
$ chmod -R 755 /var/www
$ touch /var/www/<my-domain>/html/index.html
$ nano /etc/nginx/sites-available/<my-domain>.conf
server {
listen 80;
server_name <my-domain> www.<my-domain>;
root /var/www/<my-domain>/html;
index index.html;
try_files $uri $uri/ =404;
error_page 404 /40x.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
$ ln -s /etc/nginx/sites-available/<my-domain>.conf /etc/nginx/sites-enabled/<my-domain>.conf
$ rm /etc/nginx/sites-enabled/default
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ service nginx restart