हिन्दी (Hindi)

Nginx और SSL प्रमाणपत्र (Certbot) इंस्टॉल करें

यह गाइड Nginx, वेबसाइट कॉन्फ़िग और Certbot से Let's Encrypt SSL सिखाती है।

📋 पूर्वापेक्षाएँ

  • root/sudo VPS
  • सर्वर IP पर इशारा करता डोमेन (mysite.com)
  • फ़ायरवॉल में पोर्ट 80 और 443 (UFW)

नोट: Certbot SSL के लिए डोमेन आवश्यक; IP से केवल HTTP परीक्षण।

💡 इन्फ्रास्ट्रक्चर

NVMe VPS — तेज़ डिस्क, बेहतर प्रतिक्रिया समय।

🚀 चरण 1: Nginx इंस्टॉल

Bash
sudo apt update
Bash
sudo apt install nginx -y
Bash
1# Check that Nginx is installed 2nginx -v 3 4# Check that Nginx is running 5sudo systemctl status nginx
Bash
1# Allow HTTP (port 80) 2sudo ufw allow 'Nginx HTTP' 3 4# Allow HTTPS (port 443) 5sudo ufw allow 'Nginx HTTPS' 6 7# Check rules 8sudo ufw status

ब्राउज़र: http://your-server-ip — डिफ़ॉल्ट Nginx पृष्ठ।

📝 चरण 2: वेबसाइट कॉन्फ़िग

Bash
1# Create directory (replace mysite.com with your domain) 2sudo mkdir -p /var/www/mysite.com 3 4# Set permissions 5sudo chown -R $USER:$USER /var/www/mysite.com 6sudo chmod -R 755 /var/www/mysite.com
Bash
# Create index page nano /var/www/mysite.com/index.html
HTML
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>My Website</title> 7</head> 8<body> 9 <h1>Welcome to my website!</h1> 10 <p>Your website is working correctly with Nginx.</p> 11</body> 12</html>
Bash
# Create configuration file sudo nano /etc/nginx/sites-available/mysite.com
Nginx
1server { 2 listen 80; 3 listen [::]:80; 4 5 server_name mysite.com www.mysite.com; 6 7 root /var/www/mysite.com; 8 index index.html; 9 10 location / { 11 try_files $uri $uri/ =404; 12 } 13}

महत्वपूर्ण: सभी जगह mysite.com अपना डोमेन लिखें।

Bash
1# Create symbolic link to enable the site 2sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/ 3 4# Test Nginx configuration 5sudo nginx -t
Bash
1# Remove default site 2sudo rm /etc/nginx/sites-enabled/default 3 4# Reload Nginx 5sudo systemctl reload nginx

🔒 चरण 3: Certbot और SSL

Bash
# Install Certbot and Nginx plugin sudo apt install certbot python3-certbot-nginx -y
Bash
# Obtain SSL certificate for your domain sudo certbot --nginx -d mysite.com -d www.mysite.com

Certbot पूछेगा: ईमेल, नियम स्वीकार (A), HTTP→HTTPS रीडायरेक्ट (2 अनुशंसित)।

Bash
# Check that certificate was created sudo certbot certificates

https://your-domain.com — हरा ताला 🔒

🔄 चरण 4: स्वचालित नवीनीकरण

Bash
# Test automatic renewal sudo certbot renew --dry-run
Bash
1# Check timer 2sudo systemctl status certbot.timer 3 4# If timer is not active, enable it 5sudo systemctl enable certbot.timer 6sudo systemctl start certbot.timer

🛠️ उपयोगी कमांड

Bash
1# Start Nginx 2sudo systemctl start nginx 3 4# Stop Nginx 5sudo systemctl stop nginx 6 7# Restart Nginx 8sudo systemctl restart nginx 9 10# Reload Nginx (without interruption) 11sudo systemctl reload nginx 12 13# Test configuration 14sudo nginx -t
Bash
1# Manually renew all certificates 2sudo certbot renew 3 4# View all certificates 5sudo certbot certificates
Bash
1# Nginx logs 2sudo tail -f /var/log/nginx/error.log 3sudo tail -f /var/log/nginx/access.log 4 5# Certbot logs 6sudo tail -f /var/log/letsencrypt/letsencrypt.log

🆘 समस्या निवारण

SSL इंस्टॉल नहीं: DNS (dig mysite.com), पोर्ट 80/443, server_name जाँचें।

HTTPS लोड नहीं: sudo certbot certificates, sudo ufw allow 443/tcp

❓ अक्सर पूछे जाने वाले प्रश्न

प्र: SSL मुफ़्त? उ: हाँ, Let's Encrypt via Certbot।

प्र: प्रमाणपत्र समाप्त? उ: 90 दिन; Certbot स्वचालित नवीनीकरण।

प्र: कई साइटें? उ: प्रत्येक के लिए /etc/nginx/sites-available/ में फ़ाइल।


HTTPS सुरक्षित साइट! 🚀🔒

मदद चाहिए?

इस गाइड के बारे में प्रश्न? हमारी टीम और समुदाय मदद के लिए उपलब्ध हैं।

नवीनतम ऑफ़र, छूट और विशेष प्रोमोशन से अपडेट रहें।

प्रोमोशन देखें