Two simple commands to enable and disable Nginx sites.
# Enable nginx site by name
nginx-enable-site myproject.com
# List all sites that can be enabled
nginx-enable-site --list
# Run without parameters to select site from menu
nginx-enable-site
# Disable nginx site by name
nginx-disable-site myproject.com
# List all sites that can be disabled
nginx-disable-site --list
# Run without parameters to select site from menu
nginx-disable-site
Nginx does not provide you with convenient command to manage sites.
You have to write your own command from scratch, or just deal with symlinks, but that would be tiresome.
Instead, you can just install this cutie little command and forget about this problem forever.
Syntax is very simple and straightforward.
- Read sites from folders "/etc/nginx/sites-enabled" and "/etc/nginx/sites-available"
- To enable site, it creates symlink in "/etc/nginx/sites-enabled".
- To disable site, it deletes symlink in "/etc/nginx/sites-enabled".
Option | Description |
---|---|
(no parameters) | Show interactive menu to select site |
site | Enable or disable site |
--list | List all sites that can be enabled or disabled |
To use this tool, you need NodeJS.
sudo npm install -g @nex_otaku/nginx-enable-site
- List sites
- Select site from menu
- MIT license
- Copyright 2021 © Nex Otaku.