apache支持https访问
1,确定有mod_ssl,没有的话去安装,之后在httpd.conf里面加入
LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so(后面mod_ssl。So的路径可以用find来找一下)
2有了这个之后,还要一个key和crt
偷懒的办法,直接使用RHEL5中的localhost.key、localhost.crt文件 (这样的话,浏览器可能会报警提示证书有危险)
[root@localhost ~]# cd /etc/pki/tls/
[root@localhost tls]# cp certs/localhost.crt/usr/local/httpd/conf/server.crt
[root@localhost tls]# cp private/localhost.key/usr/local/httpd/conf/server.key
3我的思路是配置https访问和http访问步骤应该是差不多的,只是多一个证书,和不一样的端口443,
所以先去写一个ssl.Conf
内容如下:
NameVirtualHost*:443
<VirtualHost*:443>
ServerAdmin fengsuzhe@163.com
DocumentRoot/opt/ci123/www/html/oauth
ServerNameopen.ci123.com
SSLEngine on
SSLCertificateFile"/opt/ci123/apache/conf/server.crt"
SSLCertificateKeyFile"/opt/ci123/apache/conf/server.key"
ErrorLoglogs/open.ci123.com-ssl-error_log
CustomLoglogs/open.ci123.com-ssl-access_log common
</VirtualHost>
<VirtualHost*:443>
ServerAdmin fengsuzhe@163.com
DocumentRoot/opt/ci123/www/html
ServerName192.168.0.36
SSLEngine on
SSLCertificateFile"/opt/ci123/apache/conf/server.crt"
SSLCertificateKeyFile"/opt/ci123/apache/conf/server.key"
ErrorLoglogs/192.168.0.36-error_log
CustomLog logs/192.168.0.36-access_logcommon
</VirtualHost>
然后再去修改httpd.conf,把上面的这个文件Include进去
Include conf/vhosts/ssl.conf
同时做如下修改:
加入监听Listen 443
确保已经加载模块:
LoadModulessl_module /usr/lib64/httpd/modules/mod_ssl.so
同时修改httpd-ssl.conf,
添加:SSLCertificateFile "/opt/ci123/apache/conf/server.crt”
SSLCertificateKeyFile"/opt/ci123/apache/conf/server.key"
重启apache,即可
备注:vhost中的ssl。Conf
NameVirtualHost*:443
<VirtualHost*:443>
ServerAdmin fengsuzhe@163.com
DocumentRoot/opt/ci123/www/html
ServerName192.168.0.36
SSLEngine on
SSLCertificateFile"/opt/ci123/apache/conf/server.crt"
SSLCertificateKeyFile"/opt/ci123/apache/conf/server.key"
ErrorLoglogs/192.168.0.36-error_log
CustomLoglogs/192.168.0.36-access_log common
</VirtualHost>