hi,

i have a problem accessing my php files in my browser, i am using apache as my webserver.
it used to work properly until i messed up things.
now i don;t know what to do.

everytime i open my php files which are on
/var/www/htm/

it gives me the permission denied error.

i think i messed up with the chown and chgrp
i typed all these:

------------
# chown -R root:root /usr/local/apache
# find /usr/local/apache -type d | xargs chmod 755
# find /usr/local/apache -type f | xargs chmod 644

# chmod -R go-r /usr/local/apache/conf
# chmod -R go-r /usr/local/apache/logs
--------------------------------------

wanting to change permissions so that my apache could create a file.
now it forbids me to do anything.

even if i check on the status of my httpd
/usr/sbin/apachectl status

gives me this error:
Forbidden
you dont have permission to access /server-status on this server.
-------------------------------------
Apache/2.2.3 (Red Hat) Server at localhost Port 80

same error is given when i check my http://localhost/
Forbidden
you dont have permission to access / on this server.


in the httpd/logs/error.log it gives me this:

- (13)Permission denied: access to /denied
- (13) Permission denied: access to /favicon.ico denied

it seems to restrict me to access anything..

please help, how do i revert back to normal?
i need this to work properly again.

i've tried chmod already to my /var/www/html and /etc/httpd/

but its not working, have i missed on somthing?


thank you so much,
tinks

Dani AI

Generated

Good catch by — the root cause was that one or more directory components in the path lost the execute/search bit. When a directory lacks the execute bit the kernel denies traversal (EACCES/13), so Apache cannot enter the folder even if the files inside are readable. That produces the “Forbidden” page and the (13) Permission denied messages in the error log.

Short explanation and policy: files served by httpd need to be readable by the httpd worker; every directory on the path must be traversable (have the execute bit) for that same account. Config and log files should remain restricted to root where possible. Avoid blanket world-writable permissions — granting write to “others” is a security risk.

Useful checks (show path-mode, ACLs, SELinux) — run as root or with sudo:

stat -c "%A %n" / /var /var/www /var/www/html
getfacl /var/www/html
getenforce
restorecon -Rv /var/www/html

A safe way to fix modes without making every file executable is to give directories the search/execute bit while keeping files non-executable. One compact command that does this is:

chmod -R u=rwX,g=rX,o=rX /var/www/html

For writable upload folders give only those directories group ownership by the webserver and set the setgid bit so new files inherit the group (example: change owner to your user and group to apache, then set g+s on the upload directory). Also verify which user Apache runs as (process list or the User directive in httpd.conf) so ownership and group choices match the server user. These steps stop accidental breaks like the one fixed and keep the site secure.

just for the record, problem's solved already

i just checked the permissions of the document roots..

#namei -m /document/root/path

and the permissions were set to 644
replace it with 755

#chmod -R 755 /document/root/path ->recursively changes permission

and then

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

to check that it has the 755..

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.