配置https虚拟主机

openssl实现私有CA:

openssl实现私有CA

取消注释

[root@zhenzhu ~]# cd /usr/local/apache/conf/
[root@zhenzhu conf]# vim httpd.conf
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule ssl_module modules/mod_ssl.so //删除#
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf  //删除#

修改文件httpd-vhosts.conf

[root@zhenzhu ssl]# cd ..
[root@zhenzhu conf]# vim extra/httpd-vhosts.conf 
[root@zhenzhu conf]# tail -17 extra/httpd-vhosts.conf 
#
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/www.zhenzhu.com"
    ServerName www.zhenzhu.com
    ErrorLog "logs/www.zhenzhu.com-error_log"
    CustomLog "logs/www.zhenzhu.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/www.zhenzhu.com"
    ServerName www.zhenzhu.com
    ErrorLog "logs/www.zhenzhu.com-error_log"
    CustomLog "logs/www.zhenzhu.com-access_log" common
</VirtualHost>



[root@zhenzhu conf]#

创建目录 移动文件 重新启动服务

[root@zhenzhu conf]# mkdir -p /usr/local/apache/htdocs/{www.zhenzhu.com,blog.zhenzhu.com}
[root@zhenzhu conf]# ls /usr/local/apache/htdocs
blog.zhenzhu.com  index.html  www.zhenzhu.com
[root@zhenzhu conf]#
[root@zhenzhu conf]# mv /var/www/html/blog/* /usr/local/apache/htdocs/blog.zhenzhu.com/
[root@zhenzhu conf]# mv /var/www/html/www/* /usr/local/apache/htdocs/www.zhenzhu.com/
[root@zhenzhu conf]# apachectl stop
[root@zhenzhu conf]# apachectl start
[root@zhenzhu conf]#

修改httpd.conf 文件

[root@zhenzhu conf]# vim httpd.conf 

# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf 	//删除注释
#

#LoadModule cache_socache_module modules/mod_cache_socache.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so //删除注释
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
修改extra/httpd-ssl.conf的文件
[root@zhenzhu conf]# vim extra/httpd-ssl.conf

#   General setup for the virtual host
DocumentRoot "/usr/local/apache/htdocs/www.zhenzhu.com"
ServerName www.zhenzhu.com:443
ServerAdmin you@example.com
ErrorLog "/usr/local/apache/logs/www.zhenzhu.com_error_log"
TransferLog "/usr/local/apache/logs/www.zhenzhu.com_access_log"

#   SSL Engine Switch:

SSLCertificateFile "/usr/local/apache/conf/ssl/httpd.crt"
#SSLCertificateFile "/usr/local/apache/conf/server-dsa.crt"
#SSLCertificateFile "/usr/local/apache/conf/server-ecc.crt"

SSLCertificateKeyFile "/usr/local/apache/conf/ssl/httpd.key"
#SSLCertificateKeyFile "/usr/local/apache/conf/server-dsa.key"
#SSLCertificateKeyFile "/usr/local/apache/conf/server-ecc.key"

重启服务

[root@zhenzhu conf]# apachectl stop
[root@zhenzhu conf]# apachectl start
[root@zhenzhu conf]# ss -antl
State      Recv-Q     Send-Q         Local Address:Port         Peer Address:Port     Process     
LISTEN     0          128                  0.0.0.0:22                0.0.0.0:*                    
LISTEN     0          128                     [::]:22                   [::]:*                    
LISTEN     0          128                        *:443                     *:*                    
LISTEN     0          128                        *:8080                    *:*                    
LISTEN     0          128                        *:80                      *:*                    
[root@zhenzhu conf]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,针对你的问题:APACHE虚拟主机配置,以下是回答: 在Apache中配置虚拟主机需要在httpd.conf或者其他的配置文件中添加如下代码: ``` <VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/usr/local/apache2/htdocs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "/usr/local/apache2/logs/dummy-host.example.com-error_log" CustomLog "/usr/local/apache2/logs/dummy-host.example.com-access_log" common </VirtualHost> ``` 其中`*`表示监听所有的网络接口,`:80`表示监听80端口,`ServerAdmin`设置管理员邮箱,`DocumentRoot`设置虚拟主机的目录,`ServerName`设置虚拟主机名字,`ServerAlias`设置虚拟主机别名,`ErrorLog`和`CustomLog` 分别设置虚拟主机的错误日志和访问日志。 如果需要配置HTTPS,则需要在虚拟主机配置中添加以下代码: ``` <VirtualHost *:443> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/usr/local/apache2/htdocs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "/usr/local/apache2/logs/dummy-host.example.com-error_log" CustomLog "/usr/local/apache2/logs/dummy-host.example.com-access_log" common SSLEngine on SSLCertificateFile "/path/to/www.example.com.cert" SSLCertificateKeyFile "/path/to/www.example.com.key" SSLCACertificateFile "/path/to/www.example.com.chain" </VirtualHost> ``` 在HTTPS虚拟主机配置中,需要添加以下代码: `SSLEngine on`表示开启SSL加密引擎,`SSLCertificateFile`指定证书位置,`SSLCertificateKeyFile`指定私钥位置,`SSLCACertificateFile`指定证书链位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值