zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0
          (1) 安裝
          # aptitude install libapache2-mod-python

          (2)創建測試文件

          默認的apach root 目錄是/var/www
          在/var/www下面創建文件夾python_test,并在此目錄下面創建文件mptest.py
          內容如下:

          from mod_python import apache

          def handler(req):
          ??? req.log_error('handler')
          ??? req.content_type = 'text/html'
          ??? req.send_http_header()
          ??? req.write('Hello World')
          ??? return apache.OK



          (3)配置

          修改/etc/apache2/sites-enable/000-default

          ??? <Directory /var/www/python_test>
          ??? ??? AddHandler mod_python .py
          ??? ??? PythonHandler mptest
          ??? ??? PythonDebug on
          ??? </Directory>

          重新啟動apache2

          #/etc/init.d/apache2 restart


          (4)測試
          瀏覽器輸入 http://localhost/python_test/mptest.py
          如果能看到
          Hello World
          就說明配置成功。
          如果有錯誤或者異常就說明配置沒有成功。






          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2009-07-16 14:02 zhyiwww 閱讀(822) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 察隅县| 昌宁县| 杂多县| 白山市| 高淳县| 新干县| 菏泽市| 乌鲁木齐县| 咸丰县| 桃江县| 古浪县| 克山县| 龙川县| 获嘉县| 江阴市| 岚皋县| 济阳县| 鸡西市| 屯留县| 陆良县| 合江县| 肥城市| 固阳县| 吴堡县| 英山县| 平泉县| 淳化县| 承德市| 土默特左旗| 大姚县| 延川县| 深州市| 尉氏县| 灵石县| 开化县| 西林县| 淮南市| 集贤县| 汉中市| 独山县| 濉溪县|