0
我試圖運行我的jscript文件並將結果返回給使用CGI的客戶端。但是我不能像#!/ usr/bin/cscript.exe那樣設置第一行或者第一行,因爲jscript不支持#開始的註釋並且出錯。Apache在Windows上更改CGI解釋器
問題:如何在我的腳本的第一行沒有!#/ usr/bin/cscript.exe的情況下設置我的CGI解釋器的路徑?
我試圖運行我的jscript文件並將結果返回給使用CGI的客戶端。但是我不能像#!/ usr/bin/cscript.exe那樣設置第一行或者第一行,因爲jscript不支持#開始的註釋並且出錯。Apache在Windows上更改CGI解釋器
問題:如何在我的腳本的第一行沒有!#/ usr/bin/cscript.exe的情況下設置我的CGI解釋器的路徑?
從我相當陳舊的httpd.conf:
# However, Apache on Windows allows either the Unix behavior above, or can
# use the Registry to match files by extention. The command to execute
# a file of this type is retrieved from the registry by the same method as
# the Windows Explorer would use to handle double-clicking on a file.
# These script actions can be configured from the Windows Explorer View menu,
# 'Folder Options', and reviewing the 'File Types' tab. Clicking the Edit
# button allows you to modify the Actions, of which Apache 1.3 attempts to
# perform the 'Open' Action, and failing that it will try the shebang line.
# This behavior is subject to change in Apache release 2.0.
#
# Each mechanism has it's own specific security weaknesses, from the means
# to run a program you didn't intend the website owner to invoke, and the
# best method is a matter of great debate.
#
# To enable the this Windows specific behavior (and therefore -disable- the
# equivilant Unix behavior), uncomment the following directive:
#
#ScriptInterpreterSource registry
所以我啓用了ScriptInterpreterSource功能,檢查:
ftype JSFile
JSFile=%SystemRoot%\System32\CScript.exe "%1" %*
和使用c:\programme\xampp\cgi-bin\jscgi.js
包含:
WScript.Echo("Content-Type: text/html\n");
WScript.Echo("OK:", WScript.ScriptFullName, new Date());
成功。我沒有觸及像AddHandler,目錄或 ScriptAlias等其他設置,並且我剛剛測試了phpinfo.php和printenv.pl,看看這個 更改是否破壞了我的安裝 - 沒有。
你應該更謹慎。
更新WRT評論:
按照2.4的文檔(搜索 「ScriptInterpreterSource」)的指令仍然有效。您確定apache用戶帳戶與cscript.exe關聯.js文件嗎?
您使用的是哪個版本的Apache?我正在Apache/2.4.4上嘗試相同的設置,但它不起作用 – arzzzen
@arzzzen - 請參閱更新。 –