Deploy a Web Server
This tutorial covers how to deploy a web server using Nginx on your GoMami VPS.
Prerequisites
- A deployed VPS instance (Ubuntu 24.04 LTS recommended)
- SSH access to your server
- A domain name (optional, for virtual host configuration)
Install Nginx
Ubuntu / Debian
# Update package list
apt update
# Install Nginx
apt install -y nginx
# Start and enable on boot
systemctl start nginx
systemctl enable nginx
# Verify status
systemctl status nginx
CentOS / AlmaLinux
# Install Nginx
dnf install -y nginx
# Start and enable on boot
systemctl start nginx
systemctl enable nginx
Verify Installation
Visit http://your_server_ip in your browser. Seeing the Nginx default welcome page means installation was successful.
Configure Firewall
# UFW (Ubuntu/Debian)
ufw allow 'Nginx Full'
ufw reload
# firewalld (CentOS/AlmaLinux)
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
Deploy a Website
Basic Static Website
Place website files in the Nginx default directory:
# Default web root
ls /var/www/html/
# Create a custom page
cat > /var/www/html/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head><title>My Website</title></head>
<body><h1>Hello from GoMami!</h1></body>
</html>
EOF
Configure Virtual Hosts
Create a dedicated config for your domain:
# Create website directory
mkdir -p /var/www/example.com/html
# Create Nginx config
cat > /etc/nginx/sites-available/example.com << 'EOF'
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
EOF
# Enable site
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
# Test configuration
nginx -t
# Reload Nginx
systemctl reload nginx
Configure SSL Certificate
Use Let's Encrypt free certificates:
# Install Certbot
apt install -y certbot python3-certbot-nginx
# Request and auto-configure certificate
certbot --nginx -d example.com -d www.example.com
# Verify auto-renewal
certbot renew --dry-run
tip
Certbot automatically modifies Nginx configuration to enable HTTPS and sets up HTTP to HTTPS redirection.
Performance Optimization
Adjust in /etc/nginx/nginx.conf:
worker_processes auto;
events {
worker_connections 1024;
}
http {
# Enable Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript;
# Client caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
}
# Test and reload
nginx -t && systemctl reload nginx
Next Steps
- Docker Setup — Deploy apps with containers
- Security Hardening — Configure firewall and security