Ubuntu15.10
Apache2.4 ( sudo apt-get install apache2 )
Python3.4 ( sudo apt-get install apache2 ), "The system also has a Python2.7 of its own"
Django1.9.5 ( pip3. 4 install Django )
mod_wsgi4.5.2 (compile and install)
Django Project directory:/var/www/djangoproject has built the MySite project, Python3. 4 manage.py runserver , the browser shows it works ... Normal
. └──mysite ├──db.sqlite3 ├──manage.py └──mysite ├──__init__.py ├──settings.py ├──urls.py └──wsgi.py
launch Apache, sudo service apache2 start , browser displays Apache default webpage (var/www/html/index.html), normal
To enable Apache to find MySite, a middleware is needed: MOD_WSGI
First install Apache2-dev, (will install APXS2)
sudo apt-get install Apache2-dev
The MOD_WSGI can then be installed.
Download source package, unzip, enter directory
./config--with-python=/usr/bin/python3. 4 sudo Make Make Install
After compiling, the mod_wsgi.sowill be generated in Apache's modules directory,
Finally configuring Apache to find and execute MySite's wsgi.py script is OK.
#/etc/apache2/apache2.conf Wsgiscriptalias /mysite/var/www/djangoproject/mysite/ Mysite/wsgi.py #映射/mysite URL to wsgi.py script wsgipythonpath /var/www/djangoproject/mysite #使得可以import mysite
<directory/var/ Www/djangoproject/mysite/mysite><files wsgi.py > Require all granted </files></directory>
When MOD_WSGI is installed, it is automatically generated in the/etc/apache2/mods-enabled/ directory: Wsgi.load and wsgi.conf if not, you can also load the module manually: LoadModule wsgi_module/ Usr/lib/apache2/modules/mod_wsgi.so
Apt-get installation of Apache, configuration files, modules, log and so are scattered, if not accustomed to also can compile and install Apache
/etc/apache2/ |-- apache2.conf | '-- ports.conf |--mods-enabled | | --*. Load | '--*. conf |--conf-enabled | '--*. conf |--sites-enabled | '--*.conf
/usr/lib/apache2/modules/*.so
/var/log/apache2/*.log
Restart Apache and visit 127.0.0.1/mysite to see the Django it works ... The
Other Notes:
If you direct sudo apt-get install LIBAPACHE2-MOD-WSGI, the generated mod_wsgi.so appears to be based on the default python2.7, so if you create Python3 with wsgi.py Django,
While python2.7 does not have Django installed, when Apache accesses wsgi.py, it will appear importerror:no module named Django.core.wsgi ...
Ubuntu+django+mod_wsgi+apache configuration Process