我有一個perl.cgi
文件,該文件具有內容:CGI腳本不執行
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";
我做到了可執行文件。 (chmod a+x perl.cgi
)
然後我在同一個目錄下創建了一個新文件perl.htm
。當我在瀏覽器中運行的perl.htm
Content-type: text/html
<p><a href="perl.cgi">RUN perl.cgi</a></p>
然後我得到的輸出:它具有以下數據
Content-type: text/html
RUN perl.cgi
當我點擊RUN perl.cgi
另一個頁面打開,有輸出爲:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<h1>Hello World</h1>\n";
即perl.cgi
未執行。只顯示文件內容。
編輯:從答案和評論我來了解,我將不得不配置我的Web服務器(Apache)運行CGI腳本。我怎樣才能做到這一點?讓我知道。
您需要更詳細地描述您的Web服務器設置。 –
投票移動到http://serverfault.com但嘗試將文件重命名爲'perl.pl'。如果不是這樣,你需要正確地配置你的web服務器來執行perl cgi –