Web Server Configuration
Prerequisites
Create NGINX Configuration
cd /etc/nginx/sites-available/
sudo nano pteroca.confExample NGINX Configuration
server {
listen 80;
root /var/www/pteroca/public;
index index.php index.html index.htm;
server_name YOUR.DOMAIN.COM;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}Configuration Notes
PHP Version
Domain Name
Enable Configuration
Verify Configuration
Test NGINX Syntax
Check NGINX Status
Test in Browser
Adding SSL with Certbot
Install Certbot
Obtain SSL Certificate
Verify Auto-Renewal
NGINX Configuration After SSL
Troubleshooting
NGINX Won't Start
502 Bad Gateway
403 Forbidden
404 Not Found
Performance Optimization
Enable Gzip Compression
Browser Caching
Client Body Size
Security Hardening
Hide NGINX Version
Add Security Headers
Next Steps
Related Guides
Last updated