1. 安裝 apach2 服務器。
這個很簡單,從官網(wǎng)上下載源代碼,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
從官網(wǎng)上下載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
從官網(wǎng)下
載1.0版本Django-1.0.tar.gz,解壓縮,使用命令python setup.py install
安裝,注意,如果機器里有以前的版本,一定要把以前的版本文件完全卸載活刪除,django
不會覆蓋以前的文件。默認安裝目錄為/usr/local/lib/python2.5/site-packages/django/
5.安裝sqlite
這里使用到的數(shù)據(jù)庫為sqlite3,所以要安裝相應的包,這里 從官網(wǎng)下載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 www.example.com:80字樣的下面添加一下行:
ServerName yourIP:80
(4) 這是最重要的一步了。在有字樣# This should be changed to whatever you set
DocumentRoot to.的后面,修改<Directory> … </Directory>中間的內(nèi)容為:
<Directory “/home/af/af“>
#
# 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
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# 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
</Directory>
其中藍色部分為要修改和添加的部分,/home/af/af是Django 工程所在的目錄,aftest為項目名稱。
(5)添加media。這里以安裝Django自己提供的admin為例。
在上一步的</Directory>下面再添加
Alias /media /usr/local/lib/python2.5/site-packages/django/contrib/admin/media
<Location “/media”>
Options None
SetHandler None
Allow from all
</Location>
即可。
配置完畢。