apache移web目录后拒绝访问解决办法

abloz 2009-06-03
2009-06-03

周海汉/文

将apache的web目录由/var/www/html移到/home/zhouhh/php,结果出现下面的问题:

Forbidden

You don’t have permission to access /install/index.php on this server.


Apache/2.2.3 (CentOS) Server at 192.168.12.12 Port 80

查找apache说明,如下:


  1. 14.Why do I get a “Forbidden” message whenever I try to access a particular directory?
  2. This message is generally caused because either
    1. ◦The underlying file system permissions do not allow the User/Group under which Apache is running to access the necessary files; or
  3. ◦The Apache configuration has some access restrictions in place which forbid access to the files.
  4. You can determine which case applies to your situation by checking the error log.
    1. In the case where file system permission are at fault, remember that not only must the directory and files in question be readable, but also all parent directories must be at least searchable (i.e., chmod +x /directory/path) by the web server in order for the content to be accessible.

    1. 15.Why do I get a “Forbidden/You don’t have permission to access / on this server” message whenever I try to access my server?
  5. Search your conf/httpd.conf file for this exact string: <Files ~>. If you find it, that’s your problem – that particular container is malformed. Delete it or replace it with <Files ~ "^.ht"> and restart your server and things should work as expected.
    1. This error appears to be caused by a problem with the version of linuxconf distributed with Redhat 6.x. It may reappear if you use linuxconf again.
    1. If you don’t find this string, check out the previous question.

14.Why do I get a “Forbidden” message whenever I try to access a particular directory? This message is generally caused because either ◦The underlying file system permissions do not allow the User/Group under which Apache is running to access the necessary files; or ◦The Apache configuration has some access restrictions in place which forbid access to the files. You can determine which case applies to your situation by checking the error log. In the case where file system permission are at fault, remember that not only must the directory and files in question be readable, but also all parent directories must be at least searchable (i.e., chmod +x /directory/path) by the web server in order for the content to be accessible. ——————————————————————————– 15.Why do I get a “Forbidden/You don’t have permission to access / on this server” message whenever I try to access my server? Search your conf/httpd.conf file for this exact string: <Files ~>. If you find it, that’s your problem – that particular container is malformed. Delete it or replace it with <Files ~ "^.ht"> and restart your server and things should work as expected. This error appears to be caused by a problem with the version of linuxconf distributed with Redhat 6.x. It may reappear if you use linuxconf again. If you don't find this string, check out the previous question.

检查配置文件,将其改为如下:


  1. DocumentRoot “/home/zhouhh/php”
    1. <Directory “/home/zhouhh/php”>
    1. #
  2. Possible values for the Options directive are “None”, “All”,

  3. or any combination of:

  4. Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

  5. #
  6. Note that “MultiViews” must be named explicitly — “Options All”

  7. doesn’t give it to yo

    u.

  8. #
  9. The Options directive is both complicated and important. Please see

  10. http://httpd.apache.org/docs/2.2/mod/core.html#options

  11. for more information.

  12. #
  13. Options Indexes FollowSymLinks
    1. #
  14. AllowOverride controls what directives may be placed in .htaccess files.

  15. It can be “All”, “None”, or any combination of the keywords:

  16. Options FileInfo AuthConfig Limit

  17. #
  18. AllowOverride None
    1. #
  19. Controls who can get stuff from this server.

  20. #
  21. Order allow,deny
  22. Allow from all
    1. </Directory>
  23. <Files ~ “^.ht”>
  24. Order allow,deny
  25. Deny from all
  26. </Files>

DocumentRoot “/home/zhouhh/php” <Directory “/home/zhouhh/php”> # # Possible values for the Options directive are “None”, “All”, # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that “MultiViews” must be named explicitly — “Options All” # doesn’t give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be “All”, “None”, or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> <Files ~ “^.ht”> Order allow,deny Deny from all </Files>

问题依旧

后面发现

[zhouhh@cvttssw ~]$ ll -a
总计 22200
drwxr–r– 14 zhouhh zhouhh 4096 06-03 15:25 .
drwxr-xr-x 9 root root 4096 04-15 16:41 ..
原来是所有网页父目录都必须有可读和可执行权限的问题

[zhouhh@cvttssw ~]$ chmod +x .
一切ok,问题解决。


如非注明转载, 均为原创. 本站遵循知识共享CC协议,转载请注明来源