意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议
配置详情
本产品仅限新用户首购专享!每人限购1台,续费5折
当前配置
数据中心: {{ getconfigInfoArea(productDetailInfo) }}
套餐规格: 2 核 2 G
带宽:
系统盘 {{ validateMySplit(ProductVM.getProductappointInfoBykey(productDetailInfo,'云系统盘'),'|',1) }} 性能型
IP 数 1 个
可选配置
操作系统:
VPC:
安全组:
购买时长:
1 月
我已阅读并同意《恒创科技服务协议》
购买前请阅读协议并勾选同意

Centos环境部署ssl | 服务器HTTPS配置指南

来源:互联网 编辑:云晓生
2025-03-14 03:45:03

CentOS环境部署SSL证书实现HTTPS加密

准备工作

部署前需确保满足以下条件:

  • 已安装CentOS 7/8操作系统
  • 拥有服务器root权限
  • 域名已完成DNS解析
  • 80/443端口开放访问

Certbot工具安装

EPEL仓库启用

yum install epel-release -y

Certbot安装命令

yum install certbot python3-certbot-nginx -y  # Nginx版本
yum install certbot python3-certbot-apache -y  # Apache版本

SSL证书申请

自动验证模式(推荐)

certbot --nginx   # Nginx服务器
certbot --apache  # Apache服务器

手动验证模式

certbot certonly --manual -d example.com -d www.example.com

Web服务器配置

Nginx配置示例

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    # 其他配置...
}

Apache配置示例

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
    # 其他配置...
</VirtualHost>

证书自动续期

通过crontab设置定时任务:

0 3 * * * /usr/bin/certbot renew --quiet

验证与测试

  • 使用浏览器访问https://example.com
  • 通过SSL Labs测试评分:SSL Server Test
  • 检查证书有效期:certbot certificates

常见问题处理

证书续期失败

解决方案:停止Web服务后执行续期命令


Centos环境部署ssl | 服务器HTTPS配置指南

systemctl stop nginx && certbot renew

混合内容警告

确保网站所有资源使用HTTPS协议加载

本网站发布或转载的文章均来自网络,其原创性以及文中表达的观点和判断不代表本网站。
上一篇: 高防服务器类型全解析:如何选择最适合的防护方案? 下一篇: 为什么WordPress无法跳转到管理后台,该如何解决这个问题?