Reputation: 930
Today i've faced some problem in deployment of django project + apache2 mod_wsgi
Let's clear some facts: 1. It's not my first deployment 2. Site is responsing with mod_wsgi 3. "static" folder has 777 arguments including files and folders
My virtualhost looks like this
<VirtualHost *:80>
ServerName myproject.com
AddDefaultCharset UTF-8
ServerAdmin [email protected]
ServerAlias www.myproject.com
DocumentRoot /home/ilyas/open.tm/bin/myproject/
WSGIScriptAlias / /home/ilyas/open.tm/bin/myproject/myproject/index.wsgi
<Directory /home/ilyas/open.tm/bin/myproject>
Order deny,allow
Require all granted
</Directory>
Alias /static/ /home/ilyas/open.tm/bin/myproject/static/
<Directory /home/ilyas/open.tm/bin/myproject/static>
Order allow,deny
Require all granted
</Directory>
</VirtualHost>
My index.wsgi looks like this:
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/open.tm/local/lib/python2.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/home/ilyas/open.tm/bin')
sys.path.append('/home/ilyas/open.tm/bin/myproject')
sys.path.append('/home/ilyas/open.tm/bin/myproject/static')
sys.path.append('/home/ilyas/open.tm/bin/myproject/myproject')
# Activate your virtual env
activate_env=("/home/ilyas/open.tm/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
application = get_wsgi_application()
and finaly files section of my settings.py
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATICFILES_DIRS = (
'static', '/home/ilyas/open.tm/bin/myproject/static/',
'media', '/home/ilyas/open.tm/bin/myproject/media/',
)
MEDIA_ROOT = os.path.join(BASE_DIR, "static/")
the site is working good, I can browse pages, I can access admin backend, I can add records via backend... But STATIC files ore not loadnig "You don't have permission to access /static/image.png on this server."
Django = 1.9.2 Apache = 2.4.7
Upvotes: 4
Views: 691
Reputation: 14311
According to the docs:
https://httpd.apache.org/docs/2.4/upgrading.html
This isn't needed in 2.4:
Order allow,deny
Try removing it?
Upvotes: 2