main is for everything else (based on Linux) that might work.
Installation is fairly straightforward on *nix (Linux and Unix-type, including macOS) machines. The bash script simply needs to be saved in /usr/local/bin, as nginx-modsite, or anything easier for you to remember (provided the name doesn’t clash with an existing command).
The file then needs to be made executable, with sudo chmod +=x.
Using the command nginx-modsite, or whatever you named the script file on install, you have a few options:
-l lists all available and enabled sites.
-e SITE enables the site SITE.
-d SITE disables the site SITE
-r reloads the Nginx server, for when you have manually edited config files.
-h displays help.
If you miss out the SITE, you will be presented with a number of options:
[email protected]:/etc/nginx# nginx-modsite -e
SELECT A WEBSITE:
Enter number for website:
Then, just hit the number of the one you want, and enter.
After enabling/disabling a site, the script will ask you if you want to reload Nginx now, or you fancy doing it manually later.
Quite simple, really, and far more powerful and feature filled than a2ensite.
How does it work, then?
Again, quite simple, really.
The bash file is simply a list of functions, which can read the sites-available and sites-enabled folders, make links from sites-available to sites-enabled with ln -sf, and remove them.
You can, of course, read the latest script on the repo at GitHub, but I have included the script below, though this may become out of date:
What I’ve done is add the option -r (about 2 lines’ work), ported the code back to Linux (about one line’s work), changed the name from nginx_modsite to nginx-modsite because I think it works better, and provided branches for Ubuntu and Homebrew.