码迷,mamicode.com
首页 > Web开发 > 详细

Install Django on Apache with mod_wsgi on linux

时间:2015-02-09 20:03:09      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

--> 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

标签:

原文地址:http://www.cnblogs.com/keep-walking/p/4282057.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!