天天看点

apache虚拟目录及问题解决Forbidden

我的apache版本是2.4,安装路径是D:/php/Apache24/

按照网上教程实现在其他路径下的文件夹下的网页html,php,当做网站管理

修改D:\php\Apache24\conf下的httpd.conf

1.添加虚拟目录的节点

#配置虚拟目录

<IfModule dir_module>

#direcotory 相当于是欢迎页面

DirectoryIndex index.html index.htm index.php

#你的站点别名

Alias /wamp "E:/wamp"

<Directory E:/wamp>

#这是访问权限设置

Order allow,deny

Allow from all

</Directory>

</IfModule>

2. 注销 documentroot 路径

#DocumentRoot "D:/php/Apache24/htdocs"

3. 测试

http://localhost/

http://localhost/new.html

--------------------------

结果怎是报错

Forbidden

You don't have permission to access / on this server.

网上查找资料,解决办法很多种:

1. 

index.html是用root用户建的文件,apache权限不够。

解决方法:更改文件权限;chmod 755 index.html

2.

打开apache配置文件httpd.conf,找到这么一段:

<Directory />

     Options FollowSymLinks

     AllowOverride None

     Order deny,allow

     deny from all

     Satisfy all

</Directory>

然后试着把deny from all中的deny改成了allow,保存后重起了apache

3. 

是Apache  的配置文件httpd-vhosts.conf里,打开了扩展配置

# Virtual hosts

Include conf/extra/httpd-vhosts.conf

前面的#去掉了,就 引入了扩展配置,而扩展配置 文件里又没配好相应 的权限“Allow from all”,所以提示此错误

------------------

我试验了网上这几种办法发现还是不行,查看原因

2.4版本的apache在注销 documentroot 路径

#DocumentRoot "D:/php/Apache24/htdocs"

的同时还需要修改

#<Directory "D:/php/Apache24/htdocs">

<Directory "E:/wamp">

重启apache服务器,测试

http://localhost/wamp/

http://localhost/wamp/new.html

显示正常,终于搞定了,赞一个