1、httpd.conf修改
打开Apache目录下 conf\httpd.conf 文件,找到 Include conf/extra/httpd-vhosts.conf 这一行,删除行首#,取消注释
2、httpd-vhosts.conf配置
httpd-vhost.conf在 conf\extra\httpd-vhost.conf,打开后有一个写好的样例
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "${SRVROOT}/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log"
</VirtualHost>
DocumentRoot是我们需要配置的web项目的根目录
ServerName是你需要配置的本地域名
其他我们都可以不理,对DocumentRoot和ServerName修改即可
3、修改hosts文件
windows下通常在C:\Windows\System32\drivers\etc\下
添加ip 和我们刚刚添加的ServerName
格式如下
127.0.0.1 test.com
::1 test.com --
最后一步,重启apache服务器