centos操作系统apache服务器添加虚拟站点

修改apache/conf下的httpd.config文件

在220行左右,修改Directory标签,此为修改权限。

1
2
3
4
<Directory/>
AllowOverride All
Require all denied
</Directory>

如图所示:

在498行左右,修改Virtual hosts,去掉下面那句话的注释

1
2
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

如图所示:

修改apache/conf/extra下的httpd-vhosts文件

如果以前可以访问的前缀是 www ,在文件末尾先加上以下代码

1
2
3
4
5
6
7
8
9
10
<VirtualHost *:80>
ServerName www.huhuapin.cn
DocumentRoot "/data/wwwroot/wordpress"
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

如图所示 然后在其下面添加你所想配置的虚拟站点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/data/wwwroot/test.huhuapin.cn"
ServerName test.huhuapin.cn
ErrorLog "/data/wwwlogs/test.huhuapin.cn_error_apache.log"
CustomLog "/data/wwwlogs/test.huhuapin.cn_apache.log" common
<Directory "/data/wwwroot/test.huhuapin.cn">
SetOutputFilter DEFLATE
Options FollowSymLinks ExecCGI
Require all granted
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>

如图所示:

重启apache,然后就大功告成了

评论