周海汉/文
将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说明,如下:
- 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.
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
检查配置文件,将其改为如下:
- 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 yo
u.
- #
-
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>
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协议,转载请注明来源