This guide explains how to manage websites on your Ubuntu server using the custom management system.
~/dev/
├── help.md # This help file
└── www/ # Web root directory
├── default/ # Default website
├── manage.sh # Management script
└── example.com/ # Domain-specific website
- Create a new website:
~/dev/www/manage.sh create mydomain.com
- Remove a website:
~/dev/www/manage.sh remove mydomain.com
- List all websites:
~/dev/www/manage.sh list
When you create a new website:
- A new directory is created at
~/dev/www/mydomain.com
- Nginx configuration is set up automatically
- A default index.html is created
- The site is enabled and Nginx is reloaded
When removing a website:
- The Nginx configuration is removed
- The website files remain intact
- Nginx is reloaded automatically
- Website Content:
~/dev/www/<domain>/
- Nginx Configs:
/etc/nginx/sites-available/
- Active Configs:
/etc/nginx/sites-enabled/
# Edit main page
nano ~/dev/www/mydomain.com/index.html
# Add new files
cp myfile.html ~/dev/www/mydomain.com/
# Test configuration
sudo nginx -t
# Reload configuration
sudo systemctl reload nginx
# Restart Nginx
sudo systemctl restart nginx
# Check status
sudo systemctl status nginx
# Access log
sudo tail -f /var/log/nginx/access.log
# Error log
sudo tail -f /var/log/nginx/error.log
- Always test Nginx configuration after changes:
sudo nginx -t
- Use relative paths in your HTML:
<img src="/images/logo.png"> <!-- Good -->
<img src="images/logo.png"> <!-- Might break -->
- Set proper permissions:
chmod -R 755 ~/dev/www/<domain>
- Backup before major changes:
cp -r ~/dev/www/<domain> ~/dev/www/<domain>.backup
-
If Nginx fails to start:
- Check error logs:
sudo tail -f /var/log/nginx/error.log
- Verify config:
sudo nginx -t
- Check permissions:
ls -la ~/dev/www/
- Check error logs:
-
If website is not accessible:
- Verify domain DNS points to your server
- Check Nginx config exists in sites-enabled
- Ensure no firewall blocking port 80/443
-
If changes don't appear:
- Clear browser cache
- Verify file permissions
- Check Nginx worker processes
- View this guide:
cat ~/dev/help.md
- View script help:
~/dev/www/manage.sh help
- Check Nginx docs: https://nginx.org/en/docs/
- Check logs:
sudo tail -f /var/log/nginx/error.log