हिन्दी (Hindi)

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

1 min
VPS/VDS होस्टिंग

यह गाइड 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
# Check that Nginx is installed nginx -v # Check that Nginx is running sudo systemctl status nginx
Bash
# Allow HTTP (port 80) sudo ufw allow 'Nginx HTTP' # Allow HTTPS (port 443) sudo ufw allow 'Nginx HTTPS' # Check rules sudo ufw status

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

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

Bash
# Create directory (replace mysite.com with your domain) sudo mkdir -p /var/www/mysite.com # Set permissions sudo chown -R $USER:$USER /var/www/mysite.com sudo 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
# Create symbolic link to enable the site sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/ # Test Nginx configuration sudo nginx -t
Bash
# Remove default site sudo rm /etc/nginx/sites-enabled/default # Reload Nginx sudo 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
# Check timer sudo systemctl status certbot.timer # If timer is not active, enable it sudo systemctl enable certbot.timer sudo systemctl start certbot.timer

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

Bash
# Start Nginx sudo systemctl start nginx # Stop Nginx sudo systemctl stop nginx # Restart Nginx sudo systemctl restart nginx # Reload Nginx (without interruption) sudo systemctl reload nginx # Test configuration sudo nginx -t
Bash
# Manually renew all certificates sudo certbot renew # View all certificates sudo certbot certificates
Bash
# Nginx logs sudo tail -f /var/log/nginx/error.log sudo tail -f /var/log/nginx/access.log # Certbot logs sudo 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 सुरक्षित साइट! 🚀🔒

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

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

हम cookies का उपयोग करते हैं

हम अपनी साइट पर आपके अनुभव को बेहतर बनाने के लिए एनालिटिक्स cookies का उपयोग करते हैं। कोई भी डेटा तीसरे पक्ष को नहीं बेचा जाता है। हमारे बारे में और जानें गोपनीयता नीति.