apache 默認端口是80,但只支持http。想要讓apache支持https,得讓apache監聽443端口。html
步驟以下: git
(1)vi /etc/apache2/ports.confgithub
(2)添加 Listen 443apache
下面就來配置SSL:參考文獻:http://www.laozuo.org/7676.html安全
(3)git clone https://github.com/letsencrypt/letsencrypt (下載letsencrypt)服務器
cd letsencrypt 測試
./letsencrypt-auto certonly --standalone --email 郵箱 -d wuyameiju.com -d www.wuyameiju.comui
(4)在完成Let's Encrypt證書的生成以後,咱們會在"/etc/letsencrypt/live/wuyameiju.com/"域名目錄下有4個文件就是生成的密鑰證書文件。rest
cert.pem - Apache服務器端證書
chain.pem - Apache根證書和中繼證書
fullchain.pem - Nginx所須要ssl_certificate文件
privkey.pem - 安全證書KEY文件htm
(5)mkdir /etc/apache2/ssl (建立ssl文件夾,用來存放證書)
(6)cd /etc/letsencrypt/live/wuyameiju.com/
(7)cp cert.pem chain.pem privkey.pem /etc/apache2/ssl/
(8)vi /etc/apache2/sites-available/default-ssl.conf 添加以下代碼:
DocumentRoot /var/www/html
ServerName www.wuyameiju.com
SSLEngine On
SSLOptions +StrictRequire
SSLCertificateFile /etc/apache2/ssl/cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem
SSLCertificateChainFile /etc/apache2/ssl/chain.pem
(9)保存退出:wq
(10)sudo apache2ctl configtest
sudo /etc/init.d/apache2 reload
sudo /etc/init.d/apache2 restart
(11)測試 w3m https://localhost:443 (若是看到apache首頁,說明配置成功!)