Linux CGI 500錯誤Internal Server Error

7 月 6, 2015 | | 0 comments

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Linux 讀取cgi檔案發生錯誤的訊息,若檔案權限沒有開啟,會出現500錯誤,cgi程式的權限需要設定711 或 755,程式的最前面有一行#!/usr/bin/perl,在#號前不可以有空格,開啟權限方式可以如下:(xampp 可以使用是#!/opt/lampp/bin/perl)
 

chmod 755 /opt/lampp/cgi-bin/cgi.cgi

然而若你是在Windows下取得的cgi檔案,可能需要特別注意,文字編輯軟體內,看不到的錯誤標籤^M,也是導致cgi 500錯誤原因
 

文字編輯器看起來一切正常

在vi模式下卻看見斷行間^M的符號

 

vi模式去除^M符號:wq儲存離開

 

 

本來500錯誤的頁面

 

 

修正後,正常顯示