CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

 2023-02-25    313  

主配置文件末尾添加一条配置:

[root@vm2 ~]# vim /usr/local/apache/conf/httpd.conf 

Include conf/vhosts.conf

在conf目录下新建vhosts,conf, 配置如下:

<VirtualHost 192.168.10.81:80>
DocumentRoot “/var/www/www.bangbangdj.com”
ServerName www.bangbangdj.com
<Directory “/var/www/www.bangbangdj.com”>
Options Indexes FollowSymLinks
DirectoryIndex index.html index.htm index.php
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

<VirtualHost 192.168.10.81:80>
DocumentRoot “/var/www/www.tp3.vs”
ServerName www.tp3.vs
<Directory “/var/www/www.tp3.vs”>
Options Indexes FollowSymLinks
DirectoryIndex index.html index.htm index.php
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

<VirtualHost 192.168.10.81:80>
DocumentRoot “/var/www/www.tp5.vs”
ServerName www.tp5.vs
<Directory “/var/www/www.tp5.vs”>
Options Indexes FollowSymLinks
DirectoryIndex index.html index.htm index.php
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

<VirtualHost 192.168.10.81:80>
DocumentRoot “/var/www/www.tpshop.vs”
ServerName www.tpshop.vs
<Directory “/var/www/www.tpshop.vs”>
Options Indexes FollowSymLinks
DirectoryIndex index.html index.htm index.php
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

[root@vm2 ~]#echo bangbangdj > /var/www/www.bangbangdj.com

[root@vm2 ~]# echo www.tp3.vs > /var/www/www.tp3.vs/index.html
[root@vm2 ~]# echo www.tp5.vs > /var/www/www.tp5.vs/index.html
[root@vm2 ~]# echo www.tpshop.vs > /var/www/www.tpshop.vs/index.html

 

测试:

CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

 

CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

 CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机

如果权限访问有问题报错

You don’t have permission to access / on this server

可以修改为如下,试试

Options Indexes FollowSymLinks ExecCGI

 

以上所述是小编给大家介绍的CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/34382.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。