php script 403 forbidden error

只愿长相守 提交于 2019-11-30 19:04:36

Check the permissions and also ownership of 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.

For instance, I believe* Apache is ran by default under the httpd user account, which is part of the httpd group. However, the FTP user you're logging in as (for instance ftpuser) might not be part of the httpd group. So, in copying the file you've created it under a different user account and Apache won't get execute access with 644.

* it's been a while since I've used apache, but it's similar under nginx.

Shishant

This isssue occurs if you have had denied for all in .htaccess file. Changing that resolves the issue.

I had the same problem. The .htaccess file in my root folder has this code:

<Files ~ "\.(php|php5|py|jsp|cgi|sh)$">
    Require all denied
</Files>

But there was a folder /example where I needed to call php files, so I created a .htaccess file in that specific folder with this content:

<Files ~ "\.(php)$">
    Require all granted
</Files>

Note: I am running Apache 2.4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!