1. 启用 ssl 模块
sudo a2enmod ssl
sudo apt-get install openssl
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
sudo cp server.crt /etc/ssl/certs sudo cp server.key /etc/ssl/private
7. 修改配置文件
sudo cp /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/001-ssl sudo vim 001-ssl在<VirtualHost *:80>段中,DocumentRoot一行的下方加入内容:
SSLEngine On SSLOptions +StrictRequire SSLCertificateFile /etc/ssl/certs/server.crt SSLCertificateKeyFile /etc/ssl/private/server.key端口修改为:443,即<VirtualHost *:443>(ssl的端口)
8. 重启apache
sudo /etc/init.d/apache2 force-reload sudo /etc/init.d/apache2 restart