我在我的win7上裝了appserv後再裝上activeperl,路徑是e:\appserv\perl\
剛開使跑appserv/www/cgi-bin/printenv.pl不行
查看printenv.pl的內容開頭有寫到
#!c:\prel\bin\perl.exe
之後把perl整個路徑複製到c:\perl
之後再執行printenv.pl就OK了!
但問題我試過把printenv.pl開頭的路徑改成unix-like路徑預設放perl的路徑
#!/usr/bin/perl
再次執行printenv.pl是無法執行的,之後改回
#!c:\perl\bin\perl.exe
又正常可以執行了!
但我有下載到一個cgi程式他的perl預設解析路徑為#!/usr/bin/perl,所以我在想要調整cgi開頭的perl解析路徑部分嗎?
所以我在想有沒有可以用apache的httpd.conf完整的取代cgi程式碼第一行開頭指定的perl路徑
在apache的httpd.conf找到
#
# Apache parses all CGI scripts for the shebang line by default.
# This comment line, the first line of the script, consists of the symbols
# pound (#) and exclamation (!) followed by the path of the program that
# can execute this specific script. For a perl script, with perl.exe in
# the C:\Program Files\Perl directory, the shebang line should be:
#!c:\perl\bin\perl.exe
不過這部分不是我要的,
之後有看到
#
#ScriptInterpreterSource registry
#
在網路上查到如果perl一直找不到解析路徑可以把它變成
#
ScriptInterpreterSource registry
#
重新執行apache後,再用printenv.pl去執行,在那個printenv.pl檔的第一行不管是#!c:\perl\bin\perl.exe還是#!/perl/bin/perl都可以正常被執行的。
所以我想問如果寫cgi程式的人不一定每個開頭perl的路徑都會一樣,想以想問只能靠apache的ScriptInterpreterSource registry讓apache去找登入檔裡面的perl路徑做解析?
還是有辦法強制在httpd.conf強制設定告訴apache perl的路徑在哪,而不用去管cgi檔上第一行的perl路徑?
另外問題剛剛發現一件事情
我把printenv.pl改成printenv.cgi卻無法執行
在apache的httpd.conf的確是有這行阿
AddHandler cgi-script .cgi .pl
怎麼會pl可以執行而cgi卻不行...,這是剛剛多出來的疑問,謝謝
自問自答,結論我發現只有pl開頭的的perl解析路徑會都參考ActivePerl的路徑,cgi就不會參考登入檔內的預設路徑。