假设你已经安装了httpd,接下来安装ssl:
yum install mod_ssl openssl
生成证书
openssl genrsa -des3 -out www.xxx.com.key 1024
注意把xxx替换成你的域名
openssl req -new -key www.xxx.com.key -out www.xxx.com.csr
openssl x509 -req -days 365 -in www.xxx.com.csr -signkey www.xxx.com.key -out www.xxx.com.crt
把3个生成的文件放到 /etc/pki/xxx.com/
然后编辑sudo vim /etc/httpd/conf/httpd.conf添加NameVirtualHost *:443 <VirtualHost *:443> DocumentRoot /var/www/html/xxx.com ServerName xxx.com:443 ServerAlias www.xxx.com SSLEngine On SSLCertificateFile /etc/pki/tls/xxx.com/www.xxx.com.crt SSLCertificateKeyFile /etc/pki/tls/xxx.com/www.xxx.com.key SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 SSLProtocol all -SSLv2 SSLHonorCipherOrder On SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 </VirtualHost>注意不要添加
listen 443
因为ssl.conf已经包含了这个,所以如果你再添加这个,就会出错,报无法绑定到端口。然后重新启动服务器如果你想让你的网站只可以使用https,那么添加:SSLRequireSSL
接下来就是重新启动httpd
sudo /etc/init.d/httpd restart然后使用https去访问你的网站试试。参考:https://jamielinux.com/articles/2013/01/enable-ssl-apache/http://www.thegeekstuff.com/2009/07/linux-apache-mod-ssl-generate-key-csr-crt-file/版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.
More from my site