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

          (2)創(chuàng)建測試文件

          默認的apach root 目錄是/var/www
          在/var/www下面創(chuàng)建文件夾python_test,并在此目錄下面創(chuàng)建文件mptest.py
          內(nèi)容如下:

          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)  編輯  收藏

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 新平| 沅陵县| 山阳县| 阳曲县| 岳西县| 八宿县| 定兴县| 祁门县| 浦城县| 淮滨县| 礼泉县| 南溪县| 营山县| 栾川县| 新巴尔虎左旗| 崇信县| 治多县| 梓潼县| 明光市| 康保县| 封开县| 吕梁市| 昂仁县| 厦门市| 大兴区| 桃江县| 康乐县| 永安市| 泽普县| 铁岭市| 景德镇市| 连山| 盐城市| 固始县| 自贡市| 恩施市| 巴中市| 隆安县| 通城县| 齐河县| 莱芜市|