首先在阿里或者其他平台申请
SSL证书(免费版)。yum -y install mod_ssl
安装后
/etc/httpd/conf.d目录下会出现一个ssl.conf文件
里面的三个文件分别填写你的ssl证书所在路径SSLCertifiCateFile 对应的public.crt路径
SSLCertifiCateChainFile 对应的chain.crt
SSLCertifiCateKeyFile 对应的xxx.key
配置443端口在ssl.conf里面找到VirtulHost
默认端口为443
ServerName
www.unclez.top
ServerAlias *.unclez.top
完整案例:
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot "/var/www/html/xxx"
ServerName www.xxx.com
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/httpd/cert/public.crt
SSLCertificateKeyFile /etc/httpd/cert/xxx.com.key
##SSLCertificateChainFile /etc/httpd/cert/chain.crt
</VirtualHost>
保存退出检查配置是否正确service httpd configtest
返回ok就没问题
重启service httpd restart