Apache 403 Forbidden Error and this one ugly..

My server is Unmanaged - So I tried hared to fix this but I can't.. Please help me..

If I create any directory http://www.myurl.com/anything =I got Forbidden error.
If I Put any .php file http://www.myurl.com/anything.php =I got Forbidden ERROR.
If I Put any .cgi file http://www.myurl.com/anything.cgi =I got Forbidden ERROR.

Only .html and htm files works.. ever phpinfo.php files shows Forbidden ERROR. :(

Please help me out.. I'll be very grateful..

Thank you.

Dani AI

Generated

Summary and quick diagnosis tied to the thread: the server is clearly able to serve static HTML, but directory requests and any .php/.cgi requests return 403. Permissions are an obvious first area (as , and noted), but when static files work while scripts are blocked the root cause is usually one of these: an access rule in Apache or .htaccess that forbids those file types, a WAF (ModSecurity) blocking script requests (phpinfo is a common false positive), an execution-policy wrapper like suEXEC/suPHP refusing to run the script because of ownership/permission policy, SELinux file-context restrictions, or a misconfigured PHP-FPM socket/handler. The Apache error log is the single best first source of truth for which of these is happening. (httpd.apache.org)

Configuration checks to add above simple file-permission checks: confirm the virtualhost or global <Directory> and any .htaccess do not explicitly deny PHP/CGI (FilesMatch, Require/Order rules). Example of the kind of permit block to look for or add (replace the path with the real document root):

<Directory "/path/to/documentroot">
Options +ExecCGI FollowSymLinks
AllowOverride All
Require all granted
</Directory>

<FilesMatch ".(php|cgi|pl)$">
Require all granted
</FilesMatch>

On Apache 2.4 the new Require directives control access (old Order/Allow lines behave differently). If the error log shows "client denied by server configuration" it points to these config directives. (svn.apache.org)

Other high‑value checks with likely causes and where logs live: ModSecurity/WAF often returns 403 with a ModSecurity audit entry (phpinfo.php is a common trigger) — inspect the ModSecurity audit log or set its engine to detection-only to test. suPHP/suEXEC enforce strict ownership and will refuse to execute scripts that are owned/writable by the wrong user — check suPHP/suexec logs. When using PHP-FPM, an inaccessible unix socket (wrong listen.owner/listen.group or listen.mode) will prevent PHP from running and produce 403s. SELinux can silently block script execution if types are wrong (scripts often need httpd_sys_script_exec_t). (support.cpanel.net)

Practical triage checklist (in order): inspect the exact error-log lines for the request; search for ModSecurity audit entries; confirm which PHP handler is active (mod_php, CGI, php‑fpm) and verify the handler/socket and its permissions; verify ownership/SELinux type for the script and parents; and review any FilesMatch/.htaccess denies. If the host is responsible for WAF/suEXEC/SELinux settings, those components and their logs are typically accessible only to the host — ask them to check the WAF and suEXEC logs if the error lines point there. Avoid making content world‑writable; that fixes little and opens real risk (as warned).

Recommended Answers

All 3 Replies

Hi,

You can try this command:

#chmod 777 /var/www/html/

Because this is permission related error.

Before going to give 777 permission to ur documentroot, make sure what access you give the owner, group, and others. 777, probably is a bad idea. That will cause hacking simple.

i think we have similar problem

try to check the permissions in your document root:

#namei -m /document/root/path

if its not in the 755 permissions try to replace it until the root..

#chmod -R 755 /document/root/path ->recursively changes permission
mine was:
#chmod -R 755 /var/www/html

and then

#ls -ld /var/www/html/
#ls -ld /var/www
#ls -ls /var

to check that it has the 755 permission already..

i hope it'll work for you.

-tinks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.