在CentOS系统中配置SSL证书通常涉及以下几个步骤:
获取SSL证书:
安装Web服务器(如果尚未安装):
sudo yum install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
配置Web服务器以使用SSL证书:
/etc/httpd/conf.d/ssl.conf
或/etc/httpd/conf.d/your_domain.conf
。/etc/nginx/conf.d/your_domain.conf
。Apache示例配置:
<VirtualHost *:443>
ServerName your_domain.com
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /path/to/your/certificate.crt
SSLCertificateKeyFile /path/to/your/private.key
SSLCertificateChainFile /path/to/your/chainfile.pem
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/your_domain_error.log
CustomLog ${APACHE_LOG_DIR}/your_domain_access.log combined
</VirtualHost>
Nginx示例配置:
server {
listen 443 ssl;
server_name your_domain.com;
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
ssl_trusted_certificate /path/to/your/chainfile.pem;
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_log /var/log/nginx/your_domain_error.log;
access_log /var/log/nginx/your_domain_access.log;
}
重启Web服务器:
sudo systemctl restart httpd
sudo systemctl restart nginx
验证SSL配置:
请根据你的实际情况调整上述步骤中的路径和域名。如果你使用的是Let’s Encrypt,Certbot会自动为你创建和管理这些文件。