目前很多瀏覽器都加強了html都安全性,要求配置https。
下面都例子是在CentOS7上的Apache配置https都過程。
一、生成證書
用OpenSSL生成key和證書:
mkdir /etc/ssl/private chmod 700 /etc/ssl/private openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
二、安裝配置ssl模組
yum安裝模組
yum install mod_ssl vim /etc/httpd/conf.d/ssl.conf
配置檔案中更改下面的內容:
DocumentRoot "/var/www/html" ServerName www.xxx.net.cn:443 SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
檢驗配置:
apachectl configtest
三、重啟服務
systemctl restart httpd
這樣Apache就有了HTTPS的服務。