(1) 安裝
# aptitude install libapache2-mod-python
(2)創(chuàng)建測試文件
默認(rèn)的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>
重新啟動(dòng)apache2
#/etc/init.d/apache2 restart
(4)測試
瀏覽器輸入 http://localhost/python_test/mptest.py
如果能看到
Hello World
就說明配置成功。
如果有錯(cuò)誤或者異常就說明配置沒有成功。
|----------------------------------------------------------------------------------------|
版權(quán)聲明 版權(quán)所有 @zhyiwww
引用請注明來源 http://m.tkk7.com/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2009-07-16 14:02
zhyiwww 閱讀(820)
評論(0) 編輯 收藏