php php脚本403禁止错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1300125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php script 403 forbidden error
提问by Shishant
I have a script giving me error 403 Forbidden error, it's just a copy of another script but the difference in this is that both use another mysql class to access database.
我有一个脚本给我错误403 Forbidden error,它只是另一个脚本的副本,但不同之处在于两者都使用另一个 mysql 类来访问数据库。
My whole project is complete and this is last file so I don't want to do the whole work again for a single file.
我的整个项目已经完成,这是最后一个文件,所以我不想为单个文件再次完成整个工作。
Server logs shows that client denied by server configuration:
服务器日志显示客户端被服务器配置拒绝:
What should I look for?
我应该寻找什么?
I have tried the following:
我尝试了以下方法:
- Permissions are 644
- New file with just simple echo gives 403 too
- Changed name of folder
- 权限为 644
- 带有简单回显的新文件也给出 403
- 文件夹名称改了
However, index.phpworks perfectly.
但是,index.php工作完美。
采纳答案by Shishant
This isssue occurs if you have had denied for all in .htaccess file. Changing that resolves the issue.
如果您在 .htaccess 文件中拒绝了所有内容,则会出现此问题。更改即可解决问题。
回答by Phillip B Oldham
Check the permissions and also ownershipof the file. Generally, 403 means that the web server doesn't have the rights to read the file and therefore can't continue the request. The permissions may be set correctly, however the file might be owned by another account on the server - an account that isn't part of the same group as the account which is running the server.
检查文件的权限和所有权。通常,403 表示 Web 服务器没有读取文件的权限,因此无法继续请求。权限可能设置正确,但是文件可能由服务器上的另一个帐户拥有 - 该帐户与运行服务器的帐户不属于同一组。
For instance, I believe* Apache is ran by default under the httpduser account, which is part of the httpdgroup. However, the FTP user you're logging in as (for instance ftpuser) might not be part of the httpdgroup. So, in copying the file you've created it under a different user account and Apache won't get execute access with 644.
例如,我相信* Apache 默认在httpd用户帐户下运行,该用户帐户是httpd组的一部分。但是,您登录的 FTP 用户(例如ftpuser)可能不属于该httpd组。因此,在复制您在不同用户帐户下创建的文件时,Apache 将无法使用644.
* it's been a while since I've used apache, but it's similar under nginx.
* 好久没用apache了,不过在nginx下也差不多。
回答by Black
I had the same problem. The .htaccessfile in my root folder has this code:
我有同样的问题。将.htaccess在我的根文件夹文件中有这样的代码:
<Files ~ "\.(php|php5|py|jsp|cgi|sh)$">
Require all denied
</Files>
But there was a folder /examplewhere I needed to call php files, so I created a .htaccessfile in that specific folder with this content:
但是有一个文件夹/example需要调用 php 文件,所以我.htaccess在该特定文件夹中创建了一个包含以下内容的文件:
<Files ~ "\.(php)$">
Require all granted
</Files>
Note: I am running Apache 2.4
注意:我正在运行 Apache 2.4

