XAMPP中apache配置本地多根目录多端口

本文详细介绍了如何在Apache服务器上配置httpd.conf和httpd-vhosts.conf文件来监听多个端口,并通过正确配置目录权限解决访问时出现的403禁止访问错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.配置httpd.conf

1)、添加监听端口

在 Listen 80 后增加
Listen 8081
Listen 8082
Listen 8083 等
2)、开启虚拟站点

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

改为

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

(就是去掉注释符号#)

2.配置httpd-vhosts.conf

底部添加如下配置代码,路径根据自己项目路径填写

<VirtualHost *:8081> 
DocumentRoot "E:/work/web/ftp/pc_web" 
ServerName localhost:8081 
ServerAlias 127.0.0.1:8081 
<Directory "E:/work/web/ftp/pc_web"> 
Options Indexes FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 
</VirtualHost>

但是以“localhost:8081”访问的时候,却发现出现了“Access forbidden!”的403错误,显示没有访问权限。具体的错误信息如下:

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

Error 403

权限<Directory>权限配置的问题,在httpd.conf

XAMPP默认的设置是这样的:

#<Directory />
   AllowOverride none
    Require all denied
</Directory>

修改成下面的就可以了!

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

顺利添加完成。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值