xampp配置多个监听端口和不同的网站目录

1.配置Apache文件httpd.conf

打开xampp安装目录下的Apache-》conf文件夹下的httpd.conf,用记事本打开

首先在Listen 80端口下添加其他监听端口:

Listen 8001Listen 8002Listen 8003

然后在httpd.conf最后加入:

NameVirtualHost *:8001<VirtualHost *:8001>ServerName localhost:8001DocumentRoot "D:\Program Files\xampp\htdocs1"</VirtualHost>NameVirtualHost *:8002<VirtualHost *:8002>ServerName localhost:8002DocumentRoot "D:\Program Files\xampp\htdocs2"</VirtualHost>NameVirtualHost *:8003<VirtualHost *:8003>ServerName localhost:8003DocumentRoot "D:\Program Files\xampp\htdocs3"</VirtualHost>

然后修改如下地方:

改为:

<Directory /> #AllowOverride none #Require all denied AllowOverride all Order deny,allow Allow from all</Directory>

2.打开Windows对应的端口:8001,8002,8003

控制面板->Windows防火墙->高级设置->出站规则->新建规则,将相应的端口添加进去

3.新建网站对应的目录文件夹

4.重启Apache服务器

6.访问localhost:8001/XXX/XXX,查看结果

 

相关文章