My setup of a python3 django environment in Ubuntu 14.04

First setup a few essentail packages that is needed:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential apache2 python3-dev mysql-server
sudo apt-get install python-pip libapache2-mod-wsgi-py3
sudo pip install virtualenv
sudo pip install virtualenvwrapper

login to mysql server and


To make virtualenvwrapper starts automatically, add

source /usr/local/bin/

to .bashrc;
Make django virtual environment:

mkvirtualenv --python=/usr/bin/python3 django
workon django
pip install django
pip install mysqlclient
django-admin startproject django

create folder static and media under the project folder;
Modify to add STATIC_ROOT=os.path.join(BASE_DIR, ‘static’);
change the database settings:

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django',
        'USER': 'root',
        'PASSWORD': 'passwd',
        'HOST': 'localhost',

migrate the admin static file:

./ collectstatic

modify the apache conf:

vi /etc/apache2/sites-enabled/000-default.conf

make it looks like:

<VirtualHost *:80>
    WSGIDaemonProcess django python-path=/home/zhouanbo/django/:/home/zhouanbo/.virtualenvs/django/lib/python3.4/site-packages
    WSGIProcessGroup django
    WSGIScriptAlias / /home/zhouanbo/django/django/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Alias /robots.txt /home/zhouanbo/django/static/robots.txt
    Alias /favicon.ico /home/zhouanbo/django/static/favicon.ico
    Alias /media/ /home/zhouanbo/django/media/
    Alias /static/ /home/zhouanbo/django/static/
    <Directory /home/zhouanbo/django/static>
        Require all granted
    <Directory /home/zhouanbo/django/media>
        Require all granted
    <Directory /home/zhouanbo/django/ideas>
            Require all granted

restart the apache service:

service apache2 restart

and django should be good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *