Today I ran into some problem while deploying the django + apache2 mod_wsgi project
Let’s clarify some facts: 1. This is not my first deployment 2. The site responds with mod_wsgi 3. The “static” folder contains 777 arguments, including files and folders
My virtual host looks like
<VirtualHost *:80>
ServerName myproject.com
AddDefaultCharset UTF-8
ServerAdmin webmaster@myproject.com
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
site.addsitedir('~/.virtualenvs/open.tm/local/lib/python2.7/site-packages')
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_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 the final section of my settings files .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 works well, I can browse the pages, I can access the backend administrator, I can add entries through the backend ... But static ore files are not loadnig "You do not have permission to access /static/image.png on this server."
Django = 1.9.2 Apache = 2.4.7