首先找到Apache的配置文件httpd.conf
确认有下面一行:
# Virtual hosts Include "conf/extra/httpd-vhosts.conf"
同时在httpd.conf启用如下:
ServerName localhost:80 #如果不启用会报错如下:
同时还要 :去掉#NameVirtualHost *:80前面的 # 号,不然会报错如下:
如果没有,请在配置文件末尾添加。然后找到httpd-vhosts.conf添加配置。配置文件如下:
2.对 httpd-vhosts.conf 进行配置
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data/website/web1"
ServerName x.com
ErrorLog "logs/x.com-error.log"
CustomLog "logs/x.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmas