安装apache
sudo apt-get install apache2
安装mysql
sudo apt-get install mysql-server
sudo apt-get install python-mysqldb
安装wsgi
sudo apt-get install libapache2-mod-wsgi
安装django
sudo apt-get install python-setuptools
sudo easy_install django
在/var/www下建个项目
cd /var/www
django-admin.py startproject mysite
然后进入mysite
cd mysite
sudo mkdir apache
cd apache
sudo vim django.wsgi
django.wsgi内容如下:
配置apache创建一个新站点
sudo vim /etc/apache2/sites-available/mysite
内容如下:
在hosts中添加一下域名
sudo vim /etc/hosts
添加 127.0.0.1 mysite.com
激活站点,重启apache
a2ensite mysite
/etc/init.d/apache2 restart
sudo apt-get install apache2
安装mysql
sudo apt-get install mysql-server
sudo apt-get install python-mysqldb
安装wsgi
sudo apt-get install libapache2-mod-wsgi
安装django
sudo apt-get install python-setuptools
sudo easy_install django
在/var/www下建个项目
cd /var/www
django-admin.py startproject mysite
然后进入mysite
cd mysite
sudo mkdir apache
cd apache
sudo vim django.wsgi
django.wsgi内容如下:
import os
import sys
path = '/var/www/mysite'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
配置apache创建一个新站点
sudo vim /etc/apache2/sites-available/mysite
内容如下:
<VirtualHost *:80>
ServerName mysite.com
DocumentRoot /var/www/mysite
<Directory /var/www/mysite>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /var/www/mysite/apache/django.wsgi
</VirtualHost>
在hosts中添加一下域名
sudo vim /etc/hosts
添加 127.0.0.1 mysite.com
激活站点,重启apache
a2ensite mysite
/etc/init.d/apache2 restart