Hello.
I new to web server and linux, but i'm trying to make one. I'ts done and workink, the only problem is that i can put apache reading the png and css files. it shows my app unformated and with broken links, when i try to open the images it showm me the 403 forbidden error. can anyonbe explain me why??

Dani AI

Generated

reported PNG and CSS returning 403 Forbidden. Since asked about an .htaccess file and confirmed none is used, the problem is more likely one of three things: filesystem permissions (including execute bit on directories), SELinux file context on CentOS, or an Apache directory/alias restriction (including symlink handling). 403 means "server refuses access" rather than "file not found."

Quick triage (run as root or with sudo) to see the exact cause and log messages:

curl -I http://server.example/path/to/file.png
tail -n 80 /var/log/httpd/error_log
ls -l /var/www/html/path/to/file.png
ls -ld /var/www/html /var/www/html/path
grep -i avc /var/log/audit/audit.log || true

If the error log contains phrases like "client denied by server configuration" or "permission denied", that points to Apache config or filesystem permissions. If /var/log/audit/audit.log shows "avc: denied", SELinux is blocking access.

Common fixes (apply cautiously):

# make directories traverseable and files world-readable
find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;
# optionally make apache the owner (not strictly required if permissions allow read)
chown -R apache:apache /var/www/html

SELinux is a frequent cause on CentOS. Check and fix labels:

getenforce
ls -Z /var/www/html/path/to/file.png
# temporary test (do NOT leave disabled on production)
setenforce 0
# permanent relabel (install semanage if missing)
yum install -y policycoreutils-python
semanage fcontext -a -t httpd_sys_content_t "/var/www/html(/.*)?"
restorecon -Rv /var/www/html

Also review Apache <Directory> or Alias blocks for accidental "Deny from all" or missing "Allow from all" (CentOS 6 / httpd 2.2 uses Order allow,deny / Allow from all) and ensure FollowSymLinks is allowed for symlinked content:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Most 403s for static files on CentOS are resolved by correcting directory/file permissions or restoring the httpd SELinux context; the error_log and audit log will indicate which one.

Recommended Answers

All 3 Replies

Hi, are you using an .htaccess file? If yes, can you post the contents here?

i'm not using .htaccess. It's soposed to use?

No, I'm trying to understand what kind of configuration is used. The 403 error happens when the clients tries to access to a restricted directory. So try to apply these suggestions: http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/

Or post here more information about the broken links and the configuration files.

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.