1.配置wamp网站地址:
找到wamp的安装目录,如~\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
打开httpd-vhosts.conf文件
其中有默认的样例:
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
我们配置自己的网站时,可以简单点:
DocumentRoot "e:demo/test01" (这里是要设置站点的路径)
ServerName test01.com (这里是要设置站点的域名)
设置好后保存,有任何改动了配置的操作都要重新启动wamp。
2.配置Apache:
打开httpd.conf文件,可参考:https://www.cnblogs.com/junglexj/p/6016755.html
将其中
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
第二行“#”去掉,表示允许;
再找到之前
# AllowOverride none
# Require all denied
3.配置hosts文件
目录:C:\Windows\System32\drivers\etc\hosts
在最下面添加一行
127.0.0.1 test01.com
保存退出,若无法保存请copy一份hosts文件到桌面编辑,再替换到C:\Windows\System32\drivers\etc目录下即可。
可以在新建一个php文件测试,e:/demo/test01/index.php
其中index.php的内容为:
echo "hello world";
?>
保存,在浏览器访问https://test01.com/test01/便可显示 "hello world" ;
注意,若是修改过默认端口,访问时要在域名后面加端口号,比如:https://test01.com:8080/test01/