Prerequisities installed:
- Python + Django
- psycopg2 (PostgreSQL adapter for Python)
- PostgreSQL server (can be on separate machine)
The installation itself:
sudo apt-get install libapache2-mod-wsgi
This command will install not only mod_wsgi, but also Apache2 webserver.
Webserver configuration:
Starting point:
http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/
What does that mean in shortness?
- Create apache/django.wsgi in your project directory as recommended.
- Add line with WSGIScriptAlias (for Django code) and AliasMatch (for CSS) directive into /etc/apache2/conf.d/security (included from /etc/apache2/apache2.conf) pointing to your apache/django.wsgi.
- Restart webserver: sudo /etc/init.d/apache2 restart.
- Test it accessing localhost via HTTP (http://localhost/admin or http://localhost).
Contents of /home/django/DSBIS/apache/django.wsgi:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'DSBIS.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
sys.path.append('/home/django')
Contents of /etc/apache2/conf.d/security:
It's working.
Further reading:
http://docs.djangoproject.com/en/dev/howto/deployment/
http://djangobook.com/en/2.0/chapter12/
NOTE: This configuration of Apache is not final, I did further changes, but it will be subject of another article on this blog.
Žiadne komentáre:
Zverejnenie komentára