A simple utility to manage Nginx configurations.

Add README

+49
+49
README.md
··· 1 + # NX - Nginx Site Manager 2 + 3 + A lightweight, colorized Bash utility to manage Nginx virtual hosts using the sites-available / sites-enabled pattern. It replaces the need for manual ln -s and rm commands with a simple, human-readable interface. 4 + 5 + ## Features 6 + 7 + * Tree-view Listing: Automatically groups subdomains under their parent domains using ASCII logic. 8 + * Status Indicators: Color-coded feedback for "Enabled" (Green) and "Disabled" sites. 9 + * Smart Suffixes: Automatically handles .conf extensions so you don't have to type them. 10 + * Integrated Testing: Prompts to run nginx -t and reload the service after every edit or toggle. 11 + * Config Preview: Uses batcat (with syntax highlighting) if installed, otherwise falls back to cat. 12 + 13 + ## Installation 14 + 15 + To install nx system-wide while keeping the source code in this repository for easy updates: 16 + 17 + 1. Move the repository to a permanent location: 18 + mkdir -p ~/projects 19 + mv nx-manager ~/projects/ 20 + cd ~/projects/nx-manager 21 + 22 + 2. Make the script executable: 23 + chmod +x nx 24 + 25 + 3. Create a symbolic link in your PATH: 26 + sudo ln -s $(pwd)/nx /usr/local/bin/nx 27 + 28 + ## Usage 29 + 30 + Most commands require sudo to modify Nginx directories and reload the service. 31 + 32 + - List sites: sudo nx list (or nx l) 33 + - Enable site: sudo nx enable mydomain.com 34 + - Disable site: sudo nx disable mydomain.com 35 + - Edit config: sudo nx e mydomain.com 36 + - Print config: nx p mydomain.com 37 + 38 + ## Environment Variables 39 + 40 + The edit command respects your preferred editor. You can set this in your ~/.bashrc or ~/.zshrc: 41 + 42 + export EDITOR='emacs' 43 + 44 + Note: To ensure your personal $EDITOR setting is picked up when running with sudo, use the -E flag: 45 + sudo -E nx e mydomain.com 46 + 47 + ## License 48 + 49 + MIT