1、vi conf/httpd.conf

查找 #Include conf/extra/httpd-ssl.conf (删除行首的配置语句注释符号“#”保存退出)

2、vi conf/extra/httpd-ssl.conf

注释所有的 VirtualHost 里面的代码

然后在末尾加上以上代码

<VirtualHost *:443>
DocumentRoot "/www/web/smallshop/public_html"
ServerName demo.smallshop.me:443
ServerAdmin you@example.com
ErrorLog "/www/wdlinux/httpd-2.4.18/logs/error_log"
TransferLog "/www/wdlinux/httpd-2.4.18/logs/access_log"

SSLEngine on

SSLCertificateFile /www/ssl/smallshop/public.pem
SSLCertificateKeyFile /www/ssl/smallshop/213979745040220.key
SSLCACertificateFile /www/ssl/smallshop/chain.pem

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/www/wdlinux/httpd-2.4.18/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
CustomLog "/www/wdlinux/httpd-2.4.18/logs/ssl_request_log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

这样可以同时开启多个站点的https访问。

如果需要开启http强制跳转到https可以在.htaccess里面加上下面的代码

RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

如果提示SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe错误

在conf/httpd.conf里面找到LoadModule socache_shmcb_module modules/mod_socache_shmcb.so 去掉开头的#就可以了。

 posted on 2016-12-26 14:20  whlives  阅读(3948)  评论(0编辑  收藏  举报