1.首先打开apache\httpd-2.4.39-win64-VC15\Apache24\conf\extra文件夹下的httpd-vhosts.conf文件,在末尾添加下面代码,参数根据注释修改。
#站点,8089为端口号名称
<VirtualHost *:8089>
#站点名、服务器名
ServerName localhost
#站点位置
DocumentRoot "E:\ProjectWork\phpProject"
<Directory "E:\ProjectWork\phpProject">
#当请求没有指定文件的时候,显示目录
Options Indexes
#启用文件夹访问控制的文件.htaccess设置
AllowOverride All
Order allow,deny
allow from all
#请求控制
Require all granted
#默认页面,第一个最优先
DirectoryIndex index.php index.html
</Directory>
</VirtualHost>
2.找到apache\httpd-2.4.39-win64-VC15\Apache24\conf文件下httpd.conf文件,把#Include conf/extra/httpd-vhosts.conf把前面的#去掉,这是代表开启,要使用conf/extra/httpd-vhosts.conf这个文件。
3.C:\Windows\System32\drivers\etc\hosts文件中末尾,找到如下图所示
4.站点配置完成。