Logo

Armand.nz

Home / About / Linkedin / Github

NGINX OSS enable and disable website

#nginx |

Symbolic links are a popular way to enable/disable websites on NGINX OSS

Note: NGINX Plus customers are recommended to store files within /etc/nginx/conf.d and not use symlinks

Enable website config

If you have installed the nginx package from the Ubuntu repositories, you will have two directories.

/etc/nginx/sites-enabled and /etc/nginx/sites-available

In the main nginx configuration,/etc/nginx/nginx.conf, you have the following line:

include /etc/nginx/sites-enabled/*.conf;

So basically to list all available virtualhosts, you can run the following command

ls /etc/nginx/sites-available

To activate one of them, run the following command

ln -s /etc/nginx/sites-available/www.example.org.conf /etc/nginx/sites-enabled

The scripts that comes with Apache is basically just simple shell wrappers that does something similar as above

After linking the files, remember to reload Nginx:

sudo service nginx reload

Disable website config

Just remove the symlink in /etc/nginx/sites-available`

rm /etc/nginx/sites-enabled/www.example.org.conf

After linking the files, remember to reload Nginx:

sudo service nginx reload
comments powered byDisqus

Copyright © Armand