现在的位置: 首页 > 综合 > 正文

ubuntu下安装django

2013年05月13日 ⁄ 综合 ⁄ 共 711字 ⁄ 字号 评论关闭

1.去页面http://www.djangoproject.com/download/下载,按照步骤安装

 

2.安装apache mod python

sudo apt-get install libapache2-mod-python

 

这是在/etc/apache2/mods-enabled文件夹下会有python.load, 自动载入mod_python模块

 

3.进入到apache的/var/www/


运行
django-admin.py startproject project

创建一个项目

 

4.apache中挂接Django

 

修给/etc/apache2/apache2.conf

 

cd /etc/apache2/apache2.conf

sudo cp apache2.conf  apache2.conf.0808

 

cat <<<END >apache2.conf

 

<Location "/project/">
SetHandler python-program
    PythonPath "sys.path+['/var/www/']"  #注意方括号中的路径,为项目文件夹的父目录
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project.settings  #注意这个名字
PythonDebug On
</Location>
END

然后重启Apache,访问http://localhost/project/,就可以看到亲切的django运行画面了。

 

 

 

参考http://avnpc.com/posts/view/Django_with_mod_python

【上篇】
【下篇】

抱歉!评论已关闭.