Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1100477
  • 博文数量: 1310
  • 博客积分: 3980
  • 博客等级: 中校
  • 技术积分: 8005
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-09 22:05
文章分类

全部博文(1310)

文章存档

2011年(1)

2008年(1309)

我的朋友

分类:

2008-11-09 16:01:37

1. 安装 apach2 服务器。
这个很简单,从官网上下载源代码,httpd-2.2.9.tar.gz,解压缩后 configure , make ,make install. 会安装在/usr/local/目录下。
使用命令/usr/local/apache2/bin/apachectl start     开启apache服务。
使用命令/usr/local/apache2/bin/apachectl stop     停止apache服务。
使用命令/usr/local/apache2/bin/apachectl restart 重新启动apache服务。

2. 安装python 2.5
从官网上下载2.5版本,Python-2.5.2.tgz,解压缩后./configure, make , make install.就可以完成安装。默认安装目录为/usr/local/lib/python2.5/
3. 安装mod_python.
./configure –with-apxs=/usr/local/apache2/bin/apxs –with-python=/usr/bin/python2.5,再make, make install 即可。安装完毕后会在目录/usr/local/apache2/modules下有文件mod_python.so,这个在后面要使用到。
4. 安装django 1.0
从下 载1.0版本Django-1.0.tar.gz,解压缩,使用命令python setup.py install 安装,注意,如果机器里有以前的版本,一定要把以前的版本文件完全卸载活删除,django 不会覆盖以前的文件。默认安装目录为/usr/local/lib/python2.5/site-packages/django/
5.安装sqlite
这里使用到的数据库为sqlite3,所以要安装相应的包,这里 从官网下载pysqlite-2.3.5.tar.gz,安装很容易。
6.配置文件.
这里使用了最简单的配置方法,直接修改/usr/local/apache2/conf/httpd.conf
(1) ,默认端口,80,可以不修改。
(2) 在有LoadModule example字样的下面添加一下一行
LoadModule python_module modules/mod_python.so
(3) 配置ServerName,在有 #ServerName 字样的下面添加一下行:
ServerName yourIP:80
(4) 这是最重要的一步了。在有字样# This should be changed to whatever you set DocumentRoot to.的后面,修改中间的内容为:


#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important. Please see
#
# for more information.
#
#Options Indexes FollowSymLinks
#PythonHandler django.core.handlers.modpython
PythonPath “['/home/af/af','/usr/local/lib/python2.5/site-packages'] + sys.path”
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE aftest.settings
SetHandler python-program
PythonDebug On

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
#AllowOverride None

#
# Controls who can get stuff from this server.
#
#Order allow,deny
Allow from all

其中蓝色部分为要修改和添加的部分,/home/af/af是Django 工程所在的目录,aftest为项目名称。
(5)添加media。这里以安装Django自己提供的admin为例。
在上一步的下面再添加
Alias /media /usr/local/lib/python2.5/site-packages/django/contrib/admin/media

Options None
SetHandler None
Allow from all

即可。

配置完毕。



seal 2008-11-06 15:59 发表评论
阅读(297) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~