1.安装apache
sudo apt-get install tasksel
sudo tasksel install lamp-server (apache,php,mysql)
2.enable rewrite 模块
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/rewrite.load
3.创建虚拟主机配置文件:
(1)cd /etc/apache2/sites-avaliable中,创建xxx.test.com
(2)文件内容:
<VirtualHost *:80>
ServerName jsli.django.com
ServerAlias jsli.django.com
ServerAdmin webmaster@localhost
RewriteEngine On
RewriteOptions Inherit
WSGIScriptAlias / /srv/api/dj_dev/dj_dev/wsgi.py #这个文件,是django startproject 自动生成的,enable 执行python必须要这句
DocumentRoot /srv/api/dj_dev
<Directory /srv/api/dj_dev>
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/jsli.django.com-error.log
CustomLog /var/log/apache2/jsli.django.com-access.log combined
</VirtualHost>
(3)cd /etc/apache2/sites-enabled
sudo ln -s ../sites-avalibale/xxx.test.com
(4)增加host映射
sudo vim /etc/hosts
添加: 127.0.0.1 xxx.test.com
(5)重启apache
sudo /etc/init.d/apache2 reload #重载配置
sudo /etc/init.d/apache2 restart #重启 apache
4.apache 运行python
(1)mod_python方式
通过lamp-server安装apache,是不带有mod python模块的
需要安装mod_python模块
获取mod_python
Mod_Python (http://www.modpython.org/)
wget http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz
先安装依赖:apxs
sudo apt-get install apache2-dev,就会安装apxs2到/usr/bin/下
编译mod_python包
./configure --with-apxs2=/usr/bin/apxs2 --with-python=/usr/bin/python
make
sudo make install
注意:编译是会有这个错误
connobject.c:142: error: request for member ‘next’ in something not a structure or union
apxs:Error: Command failed with rc=65536 |
vim src/connobject.c142行: |
!(b == APR_BRIGADE_SENTINEL(b) || 改为
enable mod_python编译通过,会在/usr/lib/apache2/modules生成mod_python.so 按照之前rewrite.load,写一个python.load |
(2)mod_wsgi方式运行python(推荐!)
./configure --with-apxs2=/usr/bin/apxs2 --with-python=/usr/bin/python
make (fatal error: Python.h: No such file or directory, 需要安装 python-dev)
sudo make install
if path not in sys.path:
sys.path.append(path)
5.django的安装
(1)mysqldb engine安装
6.django中mongodb支持
(1)安装mongoengine
7.安装setuptools
sudo apt-get install python-setuptools
8.安装pip
sudo apt-get install python-pip
9.eclipse 安装pydev 插件
直接在Eclipse中选择菜单:Help—Software Updates—Find And Install,选择 Search for new features to intall,点 New Remote Site 按钮,输入http://pydev.org/updates,下载并安装。