High-Performance Web Stack Setup
This guide walks you through deploying Nginx with PHP 8.3 FPM and securing your domain with a free, auto-renewing Let's Encrypt TLS/SSL certificate using Certbot.
1. Install Nginx and PHP 8.3 FPM
sudo apt update
sudo apt install -y nginx php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd php8.3-mbstring php8.3-xml php8.3-zip
2. Create Nginx Server Block
Create /etc/nginx/sites-available/yourdomain.com:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/yourdomain.com/public;
index index.php index.html;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ \.php\$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Enable the site and test configuration:
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
3. Issue Free Let's Encrypt SSL Certificate
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot will automatically install SSL certificates, configure HTTP-to-HTTPS 301 redirection, and schedule auto-renewal cron tasks.