httpd.conf 配置多网站 by互联网
很多时候你想在一台机器上跑多个网站,比如一个跑discuz、一个跑wordpress、一个跑其他网站...
这时候你就要需要开启apache的虚拟主机配置了。
第一步:编辑httpd.conf将vhost的注释去掉(去掉'#')
# Include conf/extra/httpd-vhosts.conf
第二步:开始配置虚拟主机
[root@csr ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf9
# 基于域名的
<VirtualHost *:80>
DocumentRoot "/data/www" # 指定你的web根目录
ServerName www.csr.com # 配置多个的时候改这里即可
</VirtualHost>
# 基于IP的
<VirtualHost 192.168.137.22:80>
DocumentRoot "/data/www1"
ServerName www.csr.com
</VirtualHost>
# 基于PORT的,只是这个还必须编辑httpd.conf加入:Listen 8080
<VirtualHost *:8080>
DocumentRoot "/data/www2"
ServerName www.csr.com
</VirtualHost>
对于http,默认端口是80,如果是基于端口的,用户每次请求还需要输入port,而且很多用户甚至不懂的怎么做,所以这种方法不常用;
网友评论