I recently learned Python and Django and want to deploy a server on my own.
Environment: ubuntu12.04 server | apache2 | django1.6 | python2.7 | mod_wsgi
Finding a lot of references on the Internet does not work, either the old version or the method is too complicated.
Today, I found the simplest method on the Django website (djangoproject.com:
apt-get apache2
Start: sudo service apache2 start
Stop: sudo service apache2 stop
Restart: sudo service apache2 restart (common operations after configuration change)
Start the test: Enter http: // localhost in the browser
Executable program:/usr/sbin/apache2
Configuration File:/etc/apache2
Website file:/var/www
(You can change the default website location in/etc/apache2/sites-available/default. Modify DocumentRoot/var/www to your website storage address)
Apache2 is mainly configured as/etc/apache2/apache2.conf, but nothing is configured. The port is configured in ports. conf: the website root directory is in/etc/apache2/sites-available/default. Additional configuration can be written in httpd. conf (empty by default, will be configured with Include httpd. conf statement Introduction)
apt-get libapache2-mod-wsgi
3. x python:
apt-get libapache2-mod-wsgi-py3
pip django
(Pip is the python third-party package installation module. If it is not installed, use sudo apt-get install python-pip to install it)
Project Creation:
Create a project under/var/www (cd/var/www)
django-admin.py startproject mysite
The file structure is as follows:
Mysite/manage. py mysite/_ init _. py settings. py urls. py wsgi. py
Detailed process of deploying Django using wsgi can be found at Django's official website (https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi)
Add the following to httpd. conf:
WSGIScriptAlias / /path/to/mysite.com/mysite//path/to/<Directory /path/to/mysite.com/mysite><Files wsgi.py></Files></Directory>
service apache2 restart
DONE!