Linux下配置Apache Https

 

1.安装lamp运行环境

安装方法参考:http://www.niceru.com/topic/1459.html

 

2.安装SSL相关模块

安装openssl和apache的ssl模块

yum install openssl mod_ssl -y

 

3.配置Apache开启SSL

3.1 #修改httpd.conf文件,#去掉下面两行前的”#”
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf

3.2 #修改conf/extra/httpd-ssl.conf

SSLCertificateFile “/home/wwwroot/dba-china.com/ssl_crt/www.dba-china.com.crt”
SSLCertificateKeyFile “/home/wwwroot/dba-china.com/ssl_crt/www.dba-china.com.key”
SSLCertificateChainFile “/home/wwwroot/dba-china.com/ssl_crt/root_bundle.crt”

3.3配置ssl虚拟主机目录

<VirtualHost _default_:443>
DocumentRoot “/home/wwwroot/dba-china.com/frontend/web”
ServerName www.dba-china.com:443
ServerAdmin admin@dba-china.com
ErrorLog “/opt/lampp/logs/dbachina-error_log”
TransferLog “/opt/lampp/logs/dba-china-access_log”

</VirtualHost>

#############httpd-ssl.conf完整虚拟主机配置如下##################

<VirtualHost _default_:443>

# General setup for the virtual host
DocumentRoot "/home/wwwroot/dba-china.com/frontend/web"
ServerName www.dba-china.com:443
ServerAdmin admin@dba-china.com
ErrorLog "/opt/lampp/logs/dbachina-error_log"
TransferLog "/opt/lampp/logs/dba-china-access_log"

# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on

.............
SSLCertificateFile "/home/wwwroot/dba-china.com/ssl_crt/2_www.dba-china.com.crt"
SSLCertificateKeyFile "/home/wwwroot/dba-china.com/ssl_crt/3_www.dba-china.com.key"
SSLCertificateChainFile "/home/wwwroot/dba-china.com/ssl_crt/1_root_bundle.crt"

.............
<FilesMatch "\.(cgi|shtml|phtml|php)$">
 SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/opt/lampp/cgi-bin">
 SSLOptions +StdEnvVars
</Directory>

.............
CustomLog "/opt/lampp/logs/ssl_request_log" \
 "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

 

4.重启Apache

重启后即可通过 https://www.dba-china.com 访问网站。

 

 

共有 0 条评论

Top