Allan Socks
Allan Socks

Reputation: 271

403 Forbidden Error on Mac when trying to view local files using Apache

I'm experiencing a problem where I am unable to view local image files, such as a favicon .ico, .png, .svg .gif or .jpg when running apache locally. I'm using apache 2.2.26, and I am setup on a Mac using the Sites folder. Everything is running perfectly smoothly and I can even view images within my PHP and html files locally but when I type them in directly into the browsers URL field I get this error:

Forbidden

You don't have permission to access /kitten.jpg on this server.

If I try to go to a .php file or a .html file I get no such error. The page renders just fine, and like I said, if the page has image files it pulls up everything as visible. This is a minor problem since it only prevents me from seeing my favicon and from looking at images in the URL field of my browser, but it's something that I'm very curious as to why this is happening. I've checked the permissions on my files and see nothing remarkable about these particular image files. It seems that there must be something funny with the configuration files (perhaps httpd.conf? or my user.conf file?). I'm not an apache expert and any help would be appreciated. I've also tried looking this up in other posts on stackoverflow and although other people may have a similar problem as I have it never seems to be this particular problem, so I'm hesitant to move forward with those subsequent solutions. Hence my question about this specific issue. Help is appreciated, thank you.

Upvotes: 3

Views: 1403

Answers (1)

andy
andy

Reputation: 21

Can you browser your DocumentRoot? like this:

cd /Library/WebServer/Documents/

if you can ls your Documents, you do this:

sudo chown -R www-default:www-default /Library/WebServer/Documents

or

sudo chmod -R 755 /Library/Webserver/Documents

if you can not ls the doucument and you get the "permission" error, you should use root and set user and groud for yours. or set 755 Permission

Upvotes: 2

Related Questions