新聞中心
如果你在Python安裝筆記的實(shí)際應(yīng)用方面有一些不清楚的地方,或是你是在Python安裝筆記這方面的新手,你可以瀏覽我們的文章,希望會對你有所收獲,以下是文章相關(guān)內(nèi)容的詳細(xì)介紹。

成都創(chuàng)新互聯(lián)專注于博白企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站建設(shè)。博白網(wǎng)站建設(shè)公司,為博白等地區(qū)提供建站服務(wù)。全流程按需求定制網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
以下步驟是自己配置過程一些記錄。希望能對想使用mod_python的人有點(diǎn)幫助。另外請注意測試代碼的縮進(jìn)。
1.下載個(gè)新版 (注意版本問題apache和python版本)
2.拷到linux機(jī)器上,下面在命令行執(zhí)行Python安裝筆記:
- tar -zxvf mod_python-3.3.1.tgz
- cd mod_python-3.3.1
- ./configure --with-apxs=/usr/local/apache/bin/apxs
配置apxs目錄
- ./configure --with-python=/usr/bin/python2.5
配置本地python
- make
- make install
3.這些編譯完了,會在apache/modules/目錄下生成mod_python.so,大概3M左右。
4.配置apache的http.conf
- LoadModule python_module modules/mod_python.so
能用apache訪問的目錄
- #AddHandler mod_python .py
- SetHandler mod_python
- PythonHandler mod_python.publisher
- PythonDebug On
5.測試在/usr/modpython/目錄下新建一個(gè)test.py
- #coding:gb2312
- def index(req):
- req.write("hello,world!")
- return
6.運(yùn)行Python安裝筆記,啟動apache沒有錯(cuò)誤后,#p#
7.定義其他方法:
- #coding:gb2312
- def index(req):
- req.write("hello,world!")
- return
- def hello(req):
- req.write("hello!!!")
- return
8.傳遞參數(shù)
- def get(req,name=""):
- if name:
- req.write("參數(shù):"+name);
- else:
- req.write("no param.");
- return
POST表單一樣,只要參數(shù)名寫對就行。
9.python包在當(dāng)前目錄下建立一個(gè)包,然后在test.py導(dǎo)入時(shí)候會出錯(cuò),找不到包。后來修改了下方法
- import os,sys
- sys.path.append(os.path.dirname(__file__))
把當(dāng)前目錄加入到sys.path中import 自己的包
網(wǎng)站標(biāo)題:Python安裝筆記的實(shí)際應(yīng)用的九種步驟介紹
文章鏈接:http://www.5511xx.com/article/coscipd.html


咨詢
建站咨詢
