欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Ubuntu >内容正文

Ubuntu

ubuntu下安装django

发布时间:2025/3/15 Ubuntu 57 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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

总结

以上是生活随笔为你收集整理的ubuntu下安装django的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。