apache搭建https站

  1. 激活SSL模块

[html] view plain copy
sudo a2enmod ssl
重启apache2
[html] view plain copy
sudo service apache2 restart

2.
创建自签名SSL证书

[html] view plain copy
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

3.
编辑配置文件,修改描红部分
[html] view plain copy
sudo vim /etc/apache2/sites-available/default-ssl.conf
[html] view plain copy



ServerAdmin admin@example.com
ServerName your_domain.com
ServerAlias www.your_domain.com

DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

SSLOptions +StdEnvVars


SSLOptions +StdEnvVars

BrowserMatch “MSIE [2-6]” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch “MSIE [17-9]” ssl-unclean-shutdown

4.
激活SSL虚拟Host

[html] view plain copy
sudo a2ensite default-ssl.conf
重启apache2
[html] view plain copy
sudo service apache2 restart

5.
测试

[html] view plain copy
https://server_domain_name_or_IP