0
点赞
收藏
分享

微信扫一扫

ubuntu下安装django


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

举报

相关推荐

0 条评论