oneinstack 安裝 https-certbot


 

免費https?   官方安裝教程:https://certbot.eff.org/#centos6-nginx (以下是說明安裝時遇到的);

  1. 下載並修改文件權限
    wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto
    

      

  2. 執行:
    1.  ./certbot-auto --nginx certonly   或是 ./certbot-auto --nginx
      報錯:xx包........出錯;請 yum update 更新一下;
      報錯:一般情況oneinstack 把nginx 沒有安裝在 /etc 目錄:
      WARNING: unable to check for updates.
      Saving debug log to /var/log/letsencrypt/letsencrypt.log
      Error while running nginx -c /etc/nginx/nginx.conf -t.
      
      nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:15
      nginx: configuration file /etc/nginx/nginx.conf test failed
      
      Could not choose appropriate plugin: The nginx plugin is not working; there may be problems with your existing configuration.
      The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:15\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
      The nginx plugin is not working; there may be problems with your existing configuration.
      The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:15\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
      

        解決方案:執行:

      /certbot-auto --nginx --nginx-server-root=/usr/local/nginx/conf
      

       


    2. 選擇 7; 需要添加HTTPS的域名


    3. 選擇2;全部使用HTTPS



  3. 完成;此時訪問域名,便是https請求方式了。
  4. 默認免費證書時間是有限的。需要更新達到續簽; (/root/certbot-auto 為本人 certbot 安裝目錄)
    1. 手動續簽
      /root/certbot-auto renew
      

        

    2. 自動續簽
      執行:
      crontab -e
      

        寫入:每天零點到十二點更新一次;

      0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && /root/certbot-auto renew
      

        也可以:30 2 * */2 * certbot renew –pre-hook “service nginx stop” –post-hook “service nginx start”     ——  每隔兩個月凌晨2:30更新:

    3. 續簽完成:並顯示過期時間  crontab -l 可查看任務詳情;

       

  5. -結束

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM