Apache2 Deploying a Django Web site

Source: Internet
Author: User
Tags site5

The MOD_WSGI modules for the apache2 and apache2 need to be installed, and the Apache2 installation configuration is omitted.

Easy to install under Ubuntu system

sudo Install Libapache2-mod-wsgi

If it is Python3, install libapache2-mod-wsgi-py3

The version that Django uses is 1.8.2, and the wsgi.py file is automatically generated in the project directory after the project is established. A bit of manual modification, after modification:

1 Import OS2 Import SYS3 From django.core.wsgi import get_wsgi_application4 5Project_dir = Os.path.dirname(Os.path.dirname(__file__))6 ifProject_dir notinchSys.path:7Sys.path.insert (0, Project_dir)8Os.environ.setdefault ("Django_settings_module","site5.settings")9application = Get_wsgi_application ()

Next, in the /etc/apache2/sites-available/ directory, create a site configuration file, for example, named site.conf content as follows:

1<virtualhost *: the>2 ServerName site.me3 Serveralias www.site.me4ServerAdmin [email protected]163. com5   6<Directory/home/td/Django/site5>7 Require All granted8</Directory>9   TenWsgiscriptalias//home/td/django/site5/site5/wsgi.py One    A<Directory/home/td/Django/site5/site5> -<files wsgi.py> - Require All granted the</Files> -</Directory> -</VirtualHost>

Add a line of content to the/etc/hosts and set

127.0. 0.1         Site.me

Finally, the relevant settings for Apache2

1 sudo A2ensite site.conf 2 sudo service apache2 Reload

Next, enter site.me in the browser address bar to see the pages of the Django site

Apache2 Deploying a Django Web site

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.