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伺服器需要在實際的文本資訊開始之前先看見一個空行。