LoginSignup
1
2

More than 5 years have passed since last update.

[Ubuntu16.04 + Apache2.4 + Django1.9 + Python3.5 + wsgi + virtualenv]

Last updated at Posted at 2016-06-16

[Ubuntu16.04 + Apache2.4 + Django1.9 + Python3.5 + wsgi + virtualenv]

1.requirement package install

$ sudo apt-get update
$ sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3
$ sudo pip3 install virtualenv virtualenvwrapper

2.configure a Python virtual enviroiment

$ cd
$ mkdir Django1.9
$ cd Django1.9
$ django-admin.py startproject firstproject
$ cd firstproject
$ virtualenv py3.5
$ source py3.5/bin/activate
$ pip install django
$ cd firstproject
$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py collectstatic

3.configure wsgi.py

import os
import site
import sys

site.addsitedir('/home/user/Django1.9/py3.5/lib/python3.5/site-packages')
sys.path.append('/home/user/Django1.9/firstproject')
sys.path.append('/home/user/Django1.9/firstproject/firstproject')

4.configure Apache

    Alias /static /home/user/Django1.9/firstprocject/static
    <Directory /home/user/Django1.9/fistproject/static>
        Require all granted
    </Directory>

    <Directory /home/user/Django1.9/firstproject/>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess test python-path=/home/user/Django1.9/firstproject:/home/user/Django1.9/py3.5/lib/python3.5/site-packages
    WSGIProcessGroup test
    WSGIScriptAlias / /home/user/Django1.9/firstproject/firstproject/wsgi.py

5.change Owner

$ sudo chown -R :www-data ~/Django1.9

6.Apache restart

$ sudo service apache2 restart

7.Access Blowser

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2