Php – Apache2 + PHP static directory

apache-2.2PHPstatic-content

I have Apache2 and PHP5 installed. My DocumentRoot is /var/www/. All .php and .html files are served form / and its child directories well. However when I request, say, .png images I get Forbidden notice.

I'd like to dispatch a specific /static/ directory for static content.

How should I edit Apache's configuration files to be able to view static content from /static/ ?

Best Answer

i'm not sure if i understand the problem but you can:

if you want to serve static files not from /var/www/static use:

Alias /static/ /somewhere/somewhere/dir/

if your static directory is already in /var/www/static and you get forbidden error - make sure that those files are readable for user under which apache runs:

chown www-data:www-data -R /var/www/static

should fix readability issue. depending on distribution username might differs. check it by running ps faux|grep apache