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 閱讀(831) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 平果县| 仁怀市| 将乐县| 屏山县| 松潘县| 上林县| 沁水县| 罗田县| 安顺市| 荃湾区| 佳木斯市| 乌鲁木齐县| 那坡县| 久治县| 靖州| 富蕴县| 股票| 咸阳市| 类乌齐县| 旬阳县| 盐边县| 贵溪市| 营口市| 玉田县| 蓬安县| 全南县| 黔西| 简阳市| 乌兰察布市| 潜江市| 棋牌| 化州市| 大宁县| 从化市| 房产| 石楼县| 莒南县| 留坝县| 堆龙德庆县| 安图县| 南京市|