您好,欢迎访问一九零五行业门户网

怎么配置apache使用https访问

配置apache使用https访问的方法:
准备
yum install mod_ssl openssl
生成一个自签名证书
cd /etc/pki/ca
1.生成2048位的加密私钥
openssl genrsa -out server.key 2048
2.生成证书签名请求
openssl req -new -key server.key -out server.csryou are about to be asked to enter information that will be incorporatedinto your certificate request.what you are about to enter is what is called a distinguished name or a dn.there are quite a few fields but you can leave some blankfor some fields there will be a default value,if you enter '.', the field will be left blank.country name (2 letter code) [xx]:cnstate or province name (full name) []:beijinglocality name (eg, city) [default city]:beijingorganization name (eg, company) [default company ltd]:test.comorganizational unit name (eg, section) []:testcommon name (eg, your name or your server's hostname) []:test.comemail address []:test@qq.complease enter the following 'extra' attributesto be sent with your certificate requesta challenge password []:123456an optional company name []:test
3.生成类型为x509的自签名证书(有效期36500天)
openssl x509 -req -days 36500 -in server.csr -signkey server.key -out server.crt
3.配置apache服务
vim /etc/httpd/conf.d/ssl.conf
1.修改下面的内容
sslcertificatefile /etc/pki/ca/server.crtsslcertificatekeyfile /etc/pki/ca/server.key
2.重启apache
/etc/init.d/httpd restart
4.调整虚拟主机
cd /etc/httpd/conf.dvim test.conf
添加以下内容
namevirtualhost *:443<virtualhost *:443>sslengine onsslcertificatefile /etc/pki/ca/server.crtsslcertificatekeyfile /etc/pki/ca/server.key<directory /var/www/html/> allowoverride all</directory>serveradmin email@example.comdocumentroot /var/www/html/servername www.test.com</virtualhost>
5.测试访问
1.因为域名只是一个测试的,所以需要再windows下绑定hosts,自定绑定
2.访问测试
https://ip
更多相关知识,请访问!
其它类似信息

推荐信息