I am currently looking into the use of Django for one of my extra-curricular projects and needed to set up a development environment on Ubuntu. This is the log for future reference and hopefully useful for anybody needing to do the same.
Dependencies & Django Installation
Core Dependencies & Django
sudo apt-get install apache2 apache2-mpm-itk libapache2-mod-wsgi mysql-server python-django python-mysqldb
For my purposes I need a few more additional modules
sudo apt-get install python-networkx python-imaging python-pythonmagick python-markdown python-textile python-docutils python-pymongo
To test the installation you can check with this command that should print the Django version
python -c "import django; print(django.get_version())"
Django App Configuration
django-admin startproject djangotest
python manage.py runserver
This should give something like the following as output:
Django version 1.5.4, using settings ‘djangotest.settings’
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
All that remains to be configured is the Apache VHOST configuration containing the WSGI directives.
sudo vim /etc/apache2/sites-available/001-djangotest.conf
#AssignUserID USERNAME USERNAME
Require all granted
Alias /static/ /home/USERNAME/projects/python/djangotest/static/
CustomLog /home/USERNAME/projects/python/djangotest/apache/logs/access.log combined
WSGIScriptAlias / /home/USERNAME/projects/python/djangotest/djangotest/wsgi.py
WSGIDaemonProcess djangotest python-path=/home/USERNAME/projects/python/djangotest processes=2 threads=15 display-name=DjangoTest
Lastly enable the site and restart Apache
sudo a2ensite 001-djangotest
sudo service apache2 restart
PLEASE NOTE: On Ubuntu 13.10 due to Apache being now 2.4 there is a fairly important change in access permissions (which cost me some time to work out) See: http://httpd.apache.org/docs/2.4/upgrading.html#access.
Also worth noting that the binary version of mod_wsgi is not compatible with the binary version of mod_itk (you will get an error like “Unable to connect to WSGI daemon process”) as WSGI tries to access the files using the default www-data user rather than the user assigned with using mod_itk. If you need this to work you will have to compile your own version of mpm_itk.