Apache下https服务的配置

来源:互联网 发布:类似tnt的网络邮箱 编辑:程序博客网 时间:2024/06/01 10:43

1.下载证书,一般为四个文件

注意:服务器不一样,证书的数量可能不一样

214132021230522.key214132021230522.pemchain.pempublic.pem

2.在apache的配置文件(httpd.conf)中,对以下两句话取消注释

注意:第一条加载ssl,第二天引入配置文件

LoadModule ssl_module modules/mod_ssl.soInclude conf/extra/httpd-ssl.conf

3.配置httpd-ssl.conf文件,加入主机信息和证书路径

注意: 路径配置错误可能打不开服务器

Listen 443SSLPassPhraseDialog  builtinSSLSessionCache        "shmcb:/Apache24/logs/ssl_scache(512000)"SSLSessionCacheTimeout  300<VirtualHost _default_:443>DocumentRoot "E:\web\public"ServerName www.abc.com:443ServerAdmin admin@example.comSSLEngine onSSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULLSSLCertificateFile "C:\Apache24\cert\www\public.pem"SSLCertificateKeyFile "C:\Apache24\cert\www\214132021230522.key"SSLCertificateChainFile "C:\Apache24\cert\www\chain.pem"<FilesMatch "\.(cgi|shtml|phtml|php)$">    SSLOptions +StdEnvVars</FilesMatch><Directory "/Apache24/cgi-bin">    SSLOptions +StdEnvVars</Directory>BrowserMatch ".*MSIE.*" \         nokeepalive ssl-unclean-shutdown \         downgrade-1.0 force-response-1.0#   Per-Server Logging:#   The home of a custom SSL log file. Use this when you want a#   compact non-error SSL logfile on a virtual host basis.CustomLog "/Apache24/logs/ssl_request.log" \          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"</VirtualHost>

4.在网站根目录的.htaccess文件中配置跳转

<IfModule mod_rewrite.c>RewriteEngine onRewriteBase /RewriteCond %{SERVER_PORT} !^443$RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]</IfModule>
原创粉丝点击