Install Django on Apache with Mod_wsgi on Linux

Source: Internet
Author: User
Tags install django

--sudo apt-get install python-mysqldb

--Install Django

--sudo apt-get install Mysql-server

Root/root123

--sudo apt-get install apache2

--sudo apt-get install Libapache2-mod-wsgi

-MkDir ~/documents/sandbox/djcode

--Vim Firstweb.wsgi

Import OS
Import Sys
Sys.path = ['/var/www/firstweb '] + sys.path
os.environ[' django_settings_module '] = ' firstweb.settings '
Import Django.core.handlers.wsgi
application = Django.core.handlers.wsgi.WSGIHandler ()

-->sudo Apt-get Install Vim

-->cd/etc/apache2/sites-available/

-->sudo-s

-->vim firstweb.conf

<virtualhost *:80>
Wsgiscriptalias//home/plex/firstweb.wsgi

ServerName firstweb.com
alias/static/var/www/firstweb/static/

<Directory/var/www/firstweb/>

Order Allow,deny
Allow from all
</Directory>
</VirtualHost>

-->a2ensite firstweb.conf
A2dissite

-->cd/var/www

-->django-admin.py Startproject Firstweb

-->apachectl restart
Or/etc/init.d/apache2 restart
Service Apache2 Reload

-->vi/etc/hosts

-->mysql-u root-p
show databases;
Create Database Firstweb;

-->vim settings.py
DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' Firstweb ',
' USER ': ' Root ',
' PASSWORD ': ' root123 ',
' HOST ': ',
}
}

-->python manage.py syncdb
Username:root
Password:root123

-->apachectl restart

--Cp-r/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static//var/www/firstweb/

--Chown-r Www-data apc_project_test/

Install Django on Apache with Mod_wsgi on Linux

Related Article

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.