zoukankan      html  css  js  c++  java
  • Apache2.4.x与Apache2.2.x的一些区别

    改用Apache2.4一段时间了,一直没发现它和Apache2.2的有什么区别,一些基本配置都是差不多,直到前几天配置虚拟主机是才发现了一些小小的不同

    一直以来我都是在htdocs目录下配置虚拟主机的,大体上使用的方法如下:

    01.<VirtualHost *:80>
    02.    DocumentRoot  "D:/www/Apache24/htdocs"
    03.    ServerName localhost
    04.    <Directory D:/www/Apache24/htdocs>
    05.        DirectoryIndex index.html index.php
    06.    Order Deny,Allow
    07.    Allow from all
    08.    </Directory>
    09.</VirtualHost>

       但是最近我想在目录htdocs之外配置虚拟主机,还是按照上面的老套路来配置,结果出现的403错误:

    1.<STRONG>Forbidden</STRONG>
    2.You don't have permission to access / on this server.

       瞬间没了头绪,这是在Apache2.2所没有的出现过的情况啊,然后试着将虚拟主机的根目录改成htdocs目录之下,也就是

    1.DocumentRoot  "D:/www/Apache24/htdocs/test"

      发现网站又能正常运行了,反复试了多次都是同一的结果。然后我就想到底是哪个地方出现了问题,这个问题困扰了我几天,百度找了无数答案,大部分都是说目录的权限有错误,需要修改权限,或者是selinux设置的问题,可是我运行的环境是windows,所以这些情况也被排除在外;有些说是需要设置Allow from all ,也没有效果。

      通过查看错误日志,发现有那么一行:

    1.AH01630: client denied by server configuration: D:/www/

      但是我的Order指令设置都是正确的,这样我郁闷了一段时间,无意中发现了一篇文章描述Apache2.4与Apache2.2之间的一些指令的差异,刚好解决了我的问题,

      其中的一些指令已经无效,如:

    1.Order Deny,Allow<BR>Deny from all<BR>Allow from al

    取而代之的是: 

    1.Deny from all
    2.变成
    3.Require all denied
    4.  
    5.Allow from all
    6.变成
    7.Require all granted

      于是我将虚拟机配置为:

    1.<VirtualHost *:80>
    2.    DocumentRoot "D:/www/sphinx/api"
    3.    ServerName www.mysphinx.com
    4.    <Directory "D:/www/sphinx/api">
    5.    DirectoryIndex index.html index.php
    6.    Require all granted
    7.    </Directory>
    8.</VirtualHost>

      发现还是提示403错误,只不过这次的错误日志的错误变成:

    1.AH01276: Cannot serve directory D:/www/sphinx/api/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive

      这是因为里面的根目录里面没有index.html 或者 index.php,我们可以添加index.html文件或者将设置改成如下:

    1.<VirtualHost *:80>
    2.    DocumentRoot "D:/www/sphinx/api"
    3.    ServerName www.mysphinx.com
    4.    <Directory "D:/www/sphinx/api">
    5.    Options FollowSymLinks Indexes
    6.    Require all granted
    7.    </Directory>
    8.</VirtualHost>

      这样就算大功告成了,不过我敢肯定Apache2.4与Apache2.2的区别不止于此,只是我还没有发现而已,期待进一步的发现。

  • 相关阅读:
    0414结对 复利
    0619-学习进度条
    测试
    冲刺一总结
    实验四主存空间的分配和回收
    0622-软件工程学期总结
    学术诚信与职业道德有感
    《构建之法》第8、9、10章
    0512 操作系统进程调度实验
    构建之法 第6~7章读后感和对Scrum的理解
  • 原文地址:https://www.cnblogs.com/wajika/p/6562030.html
Copyright © 2011-2022 走看看