怎么配置apache使用https访问
程序员文章站
2022-04-02 15:38:59
...
配置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.csr You are about to be asked to enter information that will be incorporated into 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 blank For some fields there will be a default value, If you enter '.', the field will be left blank. Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:beijing Locality Name (eg, city) [Default City]:beijing Organization Name (eg, company) [Default Company Ltd]:test.com Organizational Unit Name (eg, section) []:test Common Name (eg, your name or your server's hostname) []:test.com Email Address []:test@qq.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:123456 An 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.crt SSLCertificateKeyFile /etc/pki/CA/server.key
2.重启Apache
/etc/init.d/httpd restart
4.调整虚拟主机
cd /etc/httpd/conf.d vim test.conf
添加以下内容
NameVirtualHost *:443 <VirtualHost *:443> SSLEngine on SSLCertificateFile /etc/pki/CA/server.crt SSLCertificateKeyFile /etc/pki/CA/server.key <Directory /var/www/html/> AllowOverride All </Directory> ServerAdmin email@example.com DocumentRoot /var/www/html/ ServerName www.test.com </VirtualHost>
5.测试访问
1.因为域名只是一个测试的,所以需要再Windows下绑定hosts,自定绑定
2.访问测试
https://Ip
更多相关知识,请访问PHP中文网!
上一篇: PHP中设置时区方法小结
下一篇: PHP面向对象之解释器模式详解
推荐阅读
-
Apache Shiro 使用手册(五)Shiro 配置说明
-
怎么使用php访问mysql表并形成XML文档
-
关于memcache的使用(入门级有关问题),memcache已经配置好,怎么才能通过使用它来加快访问速度
-
php Apache 配置后访问出现Bad Request (400)
-
apache中使用mod_gnutls模块实现多个SSL站点配置(多个HTTPS协议的虚拟主机)
-
apache虚拟主机配置: 二级目录访问跳转到其他根文件夹
-
CentOS7 配置Nginx支持HTTPS访问的实现方案
-
[优化性能]求高手精简curl的使用配置,该怎么解决
-
APACHE使用.htaccess伪静态请问怎么写?
-
win7 下apache开启 https 访问??