boa使用中常見的錯誤

來源:互聯網
上載者:User

1. 當運行boa程式時出現錯誤,如下:
# ./boa
[27/Nov/1990:13:22:25 + 0000]boa.c:266.icky Linux kernel bug!:No such file
將 User 0修改成 User nobody
2. 開啟網頁時,網頁中的圖片無法顯示
就將存放圖片的子目錄/var/www/images修改成/var/www/img
3. 在測試cgi指令碼時,當在瀏覽器地址中輸入“http//10.10.10.2/cgi-bin/helloworld.cgi”時,瀏覽輸出下述錯誤:
502 Bad Gateway
The CGI was not CGI/1.1 compliant
(注:此種錯誤在使用BOA時十分常見,原因基本都是自己寫的cgi程式的輸入輸出問題)
在目標板的調試終端中輸出下述錯誤:
……cgi_header:unable to find LFIF
上述錯誤是在boa原碼中的cgi_header .c檔案中的process_cgi_header函數產生,如下:
buf = req->header_line;
c = strstr(buf, "\n\r\n");
if (c == NULL) {
c = strstr(buf, "\n\n");
if (c == NULL) {
log_error_time();
fputs("cgi_header: unable to find LFLF\n", stderr);
//出錯資訊
#ifdef FASCIST_LOGGING
log_error_time();
fprintf(stderr, "\"%s\"\n", buf);
#endif
send_r_bad_gateway(req);
return 0;
}
}
我們可以定義FASCIST_LOGGING,使產生該錯誤時將buf內容列印出來,結果如下:
……cgi_header:unable to find LFIF
Content-type: text/html
<html>
<head><title>CGI Output</title></head>
<body>
<hl>Hello, world.</hl>
<body>
</html>
原來buf中的內容就是helloworld.c中輸出的內容,查看輸出結果,再看process_cgi_header函數中的語句:c = strstr(buf, "\n\n"),很明顯buf中沒有兩個連續的分行符號"\n\n",所以是helloworld.c檔案中的語句:printf("Content- type: text/html\n\n");錯寫成了printf("Content-type: text/html\n");
上述行通過標準輸出將字串″Contenttype:text/plain\n\n″傳送給Web伺服器。它是一個MIME頭資訊,告訴Web伺服器隨後的輸出是以純ASCII文本的形式。在這個頭資訊中有兩個新行符,這是因為Web伺服器需要在實際的文本資訊開始之前先看見一個空行。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.