Install dependence
- Install apache2
$sudo apt-get install apache2 apache2-dev
Check apxs
$ apxs2
- Install python dev
$sudo apt-get install python-dev
- Install mod_wsgi
Download from https://github.com/GrahamDumpleton/mod_wsgi/releases
$ wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz
$ tar zxvf 4.4.21.tar.gz
$ cd mod_wsgi-4.4.21
$ ./configure
or
$ ./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/bin/python
$ make
$ sudo make install
# Will create a mod_wsgi.so to modules: /usr/lib/apache2/modules/mod_wsgi.so
- Install django
$ sudo -E pip install django
# Check
$ django-admin help
# Django docs: https://www.djangoproject.com/start/
Create your Django projects
- Create an simple django project
$ django-admin startproject BobServer
# Check your project
$ cd BobServer
$ python manage.py runserver
Setup apache conf for your project
- Create django conf for apache2 http://www.rackspace.com/knowledge_center/article/ubuntu-modwsgi-installation
$ cd /etc/apache2/sites-available
$ sudo vim django.conf
# add below info
"""
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIScriptAlias /bobserver /home/bob/github/BobServer/BobServer/wsgi.py
WSGIPythonPath /home/bob/github/BobServer/:/usr/local/lib/python2.7/dist-packages/;/usr/local/bin/
<Directory /home/bob/github/BobServer>
#Options Indexes FollowSymLinks
AllowOverride None
Require all granted
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/BobServer.log
"""
# add soft link in sites-enabled
$ sudo ln -s django.conf ../sites-available/django.conf
# Restart apache2
$ sudo service apache2 restart
# To check your setup, open browser and go to your server url
# xxxxxx.com/bobserver