Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks
          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 www.example.com:80字樣的下面添加一下行:
          ServerName yourIP:80
          (4) 這是最重要的一步了。在有字樣# This should be changed to whatever you set DocumentRoot to.的后面,修改<Directory> … </Directory>中間的內容為:

          <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>

          即可。

          配置完畢。

          posted on 2008-11-06 15:59 seal 閱讀(567) 評論(0)  編輯  收藏 所屬分類: Python
          主站蜘蛛池模板: 龙胜| 汾阳市| 威信县| 寻乌县| 建宁县| 鹤岗市| 北安市| 新昌县| 日土县| 枣阳市| 随州市| 马边| 卢氏县| 铁岭县| 南川市| 区。| 磴口县| 罗山县| 吉木萨尔县| 兴国县| 花垣县| 合作市| 威宁| 高雄县| 民和| 紫金县| 凌云县| 海南省| 沙洋县| 益阳市| 海晏县| 晋中市| 牟定县| 镇平县| 安塞县| 乐平市| 固阳县| 仁寿县| 忻州市| 新津县| 隆德县|