wamp下apache配置對python的支持

在python的官方網站下載forWin的python可執行文件,運行安裝。
建議安裝在D:\python文件夾下,因爲下面還要引用這個文件夾,所以名稱越簡單越好。
在apache的http.conf文件內,修改如下黃色地方:
DocumentRoot “D:/Work/web”
<Directory “D:/Work/web/”>
Options +Indexes +FollowSymLinks +Multiviews +ExecCGI
AllowOverride all
Require local
</Directory>
<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddHandler cgi-script .cgi .py
</IfModule>

在D:\Work\web文件夾下新件一個text.py文本文件,utf-8編碼格式。
內容爲:

#!D:\python\python.exe
print("Content-type:text/html\n")
print('hello world')

這裏有幾個注意的地方:
1、第一行一定要定格寫,前面不要留空行也不要留空格
2、第一行引用的是你安裝的python.exe的位置,根據你的實際情況做調整
3、第二行一定要有,否則會報一個沒有html頭部的錯誤

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章