How to Install Nginx server on Ubuntu and SSL setup 849 مشاهدة Markdown Update Your Server sudo apt update && sudo apt upgrade -y Install Nginx Ubuntu’s default repo already includes Nginx. sudo apt install nginx -y Check status: systemctl status nginx You should see active (running). Allow Firewall (UFW) If UFW is enabled: sudo ufw allow 'Nginx Full' sudo ufw enable sudo ufw status This opens 80 (HTTP) and 443 (HTTPS). Verify Nginx is Serving Pages Open browser: Code http://your_server_ip You should see the default Nginx welcome page. Create Your Website Directory Example for domain: example.com sudo mkdir -p /var/www/example.com/html sudo chown -R $USER:$USER /var/www/example.com/html sudo chmod -R 755 /var/www/example.com Add a test file: nano /var/www/example.com/html/index.html Paste: Welcome to example.com Create Nginx Server Block sudo nano /etc/nginx/sites-available/example.com Add: nginx 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; } } Enable it: sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ Disable default site (optional): sudo rm /etc/nginx/sites-enabled/default Test Configuration sudo nginx -t If OK: sudo systemctl reload nginx Enable HTTPS (Let’s Encrypt SSL) Install Certbot: sudo apt install certbot python3-certbot-nginx -y Run: sudo certbot --nginx -d example.com -d www.example.com Auto-renew test: sudo certbot renew --dry-run Optional: Reverse Proxy Setup If you want to proxy to Node.js, Python, PHP-FPM, etc.: nginx location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } Reload: sudo systemctl reload nginx هل كان هذا مفيدًا؟ نعم لا شكرًا على ملاحظاتك! السابق How to Change a User’s Name While Keeping the Same Email ID in Microsoft 365 التالي How to Install Nextcloud on Ubuntu