Ubuntu12.04 server + apache2 + wsgi + django1.6 deployment

Source: Internet
Author: User
Tags django website

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.