How to use Django with Apache and mod_python
来源:互联网 发布:php弹出消息框 编辑:程序博客网 时间:2024/05/17 09:10
os: ubuntu 10.04
django: version 2.5
apache: 2
python: 2.6
1. install python, django, apache, mod_python
apt-get install
2.edit httpd.conf
<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"> AllowOverride None Options None Order allow,deny Allow from all </Directory> Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"<Location "/mysite"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonOption django.root /mysite PythonInterpreter mysite PythonDebug On PythonPath "['C:/Python/Django/apps'] + sys.path"</Location>
Location "/mysite" 而不要是Location "/mysite/"
设置MaxRequestsPerChild 1,这样可以在开发阶段不用重启Apache进行测试
Alias /media/是django admin 管理界面要用到的
另一種方法
cd /var/wwwsudo ln -s ~/media mediasudo ln -s ~/django_src/django/contrib/admin/media admin_media# Absolute path to the directory that holds media.# Example: "/home/media/media.lawrence.com/"MEDIA_ROOT = '/home/YOUR_USERNAME/media/'# URL that handles the media served from MEDIA_ROOT. Make sure to use a# trailing slash if there is a path component (optional in other cases).# Examples: "http://media.lawrence.com", "http://example.com/media/"MEDIA_URL = 'http://yourdomain.com/media/'# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a# trailing slash.# Examples: "http://foo.com/media/", "/media/".ADMIN_MEDIA_PREFIX = '/admin_media/'
所用到的路徑為絕對路徑
若數據庫類開為sqllite3, databasename也要是絕對路徑
- How to use Django with Apache and mod_python
- How to use Django with Apache and mod_wsgi
- How to setup Apache and mod_python and django
- How to use Django with uWSGI
- How to use Django with mod_wsgi.
- How to Install and Use JRebel with WebLogic and Eclipse
- apache+mysql+mod_python+Django
- How to use Comparator and Comparable in Java? With example
- How to use SCAN and node listeners with different ports?
- how to use adb and gdbserver with VirtualBox - KVM (qemu)
- [Python]Apache with Mod_python
- How to Setup Apache With FastCGI And Ruby Bindings
- How to configure and use Git with visual studio 2012 and TFS
- How to Use C++ With PHP and JQuery to Make Neat Apps
- How To Install and Configure Django with Postgres, Nginx, and Gunicorn
- How To Use Linux epoll with Python
- How to use Trace2UML together with Doxygen
- How To Use Linux epoll with Python
- 常见的MIME类型
- linux 获取文件大小
- 转:深入解读Linux与Android的相互关系
- 零值比较--BOOL,int,float,指针变量与“零值”比较的if语句
- Js获取当前日期时间及其它操作
- How to use Django with Apache and mod_python
- 初学C#编程的注意事项
- Java Random的参数的作用
- .net写的Email可以群发邮件
- Flex通过Java读取Excel(详细流程)----Excel在客户端(DataGrid动态根据Excel生成)
- loadrunner监控ubuntu/unix服务器
- 深入分析Linux内核源码
- Ocaml基本认识
- end_request: I/O error, dev sdi, sector 硬盘 故障