Ubuntu 10.04 下django 部署到apache服务器 - webdancer's Blog

Ubuntu 10.04 下django 部署到apache服务器

webdancer posted @ 2011年4月02日 21:40 in 工具 with tags django , 2578 阅读

由于django自带的服务器,对静态的文件支持不好。所以,决定将django工程部署到apache服务器上,下面记录一下大致的过程。

1.安装apache服务器。

sudo aptitude search apache

搜索一下,安装:

sudo aptitude install apache2

2.安装插件。django与服务器连接有好几个插件,我用的是:mod_wsgi(http://code.google.com/p/modwsgi/).在10.04下:

sudo aptitude search apache|grep wsgi

搜索一下,安装:

sudo aptitude install libapache2-mod-wsgi 

3.配置。

我的工程位于Ubuntu主目录下面,根据django的文档:

1).apache配置。

编辑/etc/httpd.conf,

 

AliasMatch ^/([^/]*\.css) ~/bookmarks/media/$1
Alias /media/ ~/bookmarks/media/

<Directory ~/bookmarks/media>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / ~/bookmarks/apache/django.wsgi

/:程序url起始位置。

~/bookmarks/apache/django.wsgi:工程目录下,新建apache目录,建立django.wsgi文件。

2)编辑django.wsgi文件:

import os
import sys

sys.path.append('~')
sys.path.append('~/bookmarks')

os.environ['DJANGO_SETTINGS_MODULE']='bookmarks.settings'

import django.core.handlers.wsgi

application=django.core.handlers.wsgi.WSGIHandler()

参考:http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/

http://code.google.com/p/modwsgi/wiki/InstallationOnLinux

记得,重新启动apache,

sudo apache2ctl restart

配置完成后,不知道为什么刚开始不行,刷了几次,就OK了。

Karnataka SSLC Quest 说:
2022年8月23日 18:01

Karnataka SSLC Question Paper 2023 Download – KSEEB 10th Class New Model Paper 2023 PDF, KSEEB is also known as Karnataka Secondary Education Examination Board. KSEEB was established in 1966; Karnataka SSLC Question Paper 2023 this board is conducting the class 10th and other board exams. KSEEB is one of the famous education board in the Karnataka state.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee