A lightweight Bash script to automate the setup and management of NGINX, domain configuration, Let's Encrypt SSL, and cleanup on Debian-based systems.
🔨🤖🔧 Ideal for developers, sysadmins, or DevOps engineers looking for quick NGINX provisioning.
- ✅ Install and start NGINX if not already installed
- 🌐 Setup new domains with:
- Custom NGINX configuration
- Optional Let's Encrypt SSL integration
- Auto-generated site directory & index.html
- Optional Certbot cron renewal
- 💥 Remove all NGINX and domain-related settings in one go (NGINX, domain dirs, SSL certs, and cron jobs)
mkdir -p uriscript && cd uriscript && curl -O https://raw.githubusercontent.com/urifallon/uriscript-nginx/main/uriscript-nginx.sh
chmod +x uriscript-nginx.sh
./uriscript-nginx.sh
You’ll be greeted with a menu:
Please select an option:
1) Install NGINX
2) Setup Domain
3) Remove All
4) Exit
- Installs NGINX if not present
- Starts and enables the service
- Prompts for:
- Your domain name (e.g.
example.com
) - Whether to enable SSL
- Whether to create a cron job for SSL renewal
- Your domain name (e.g.
- Creates:
/var/www/<yourdomain>/html/index.html
- NGINX config at
/etc/nginx/sites-available/<domain>.conf
- Symlink in
sites-enabled
- Optional Let's Encrypt certificate with Certbot
- Reloads NGINX on success
A full teardown of everything the script sets up:
- Removes NGINX and config files
- Deletes domain web root directories
- Deletes SSL certificates via
certbot delete
- Removes cron jobs that involve
certbot renew
uriscript/
├── uriscript-nginx.sh # Main interactive script
├── ...
If you want to manually reconfigure or inspect the setup:
Path | Purpose |
---|---|
/etc/nginx/sites-available/<domain>.conf |
Domain's NGINX configuration |
/etc/nginx/sites-enabled/<domain>.conf |
Symlink to enable config |
/var/www/<domain>/html/ |
Root web content (index.html) |
/etc/letsencrypt/live/<domain>/ |
SSL certs (if Let's Encrypt is enabled) |
crontab -e |
Certbot auto-renewal job (runs daily at 3AM by default) |
To edit domain manually:
sudo nano /etc/nginx/sites-available/<yourdomain>.conf
sudo systemctl reload nginx
To remove a domain:
sudo rm -rf /var/www/<yourdomain>
sudo rm /etc/nginx/sites-available/<yourdomain>.conf
sudo rm /etc/nginx/sites-enabled/<yourdomain>.conf
sudo certbot delete --cert-name <yourdomain>
# Test NGINX config syntax
sudo nginx -t
# Reload NGINX after config change
sudo systemctl reload nginx
# View all configured certbot certificates
sudo certbot certificates
# Manually renew SSL (usually done via cron)
sudo certbot renew --dry-run
# View current root crontab
sudo crontab -l
- OS: Ubuntu/Debian (tested on Ubuntu 20.04+)
- Root or sudo privileges
- Internet access (for package installation and Let's Encrypt)
- This script does not support wildcard or multi-domain SSL (e.g.,
*.domain.com
) - Ensure that DNS for the domain is pointing to the server's IP before running SSL setup
- The script is idempotent — re-running it on the same domain will prompt for confirmation
Want to revert everything? Just choose the Remove All
option in the menu and confirm twice.
This removes:
- NGINX
- Domain folders
- Certbot SSL certificates
- Cron jobs related to SSL renewal
Created by urifallon
Pull requests and suggestions welcome!