嵌入式web伺服器移植
文章目錄
- 嵌入式web伺服器移植
- 1.移植環境搭建
- 2.Lighttpd移植
- 2.1 下載原始碼並解壓
- 2.2 編譯配置
- 2.3 編譯安裝
- 2.4 Lighttpd配置
- 2.4.1 修改lighttpd.conf檔案
- 2.4.2 修改modules.conf檔案
- 2.4.3 修改conf.d資料夾中的cgi.conf檔案
- 2.4.4 修改conf.d資料夾中的cgi.conf檔案
- 2.5 Lighttpd測試
- 2.6 CGI測試
- 3.Shttpd移植
- 4.Thttpd移植
- 5.Boa移植
- 6.Mini_httpd移植
- 7.Appweb
- 8.GoAhead
嵌入式web伺服器移植
ubuntu 16.04.4
arm-linux-gnueabihf-gcc 4.7.2
arm linux 3.10
嵌入式web伺服器,是web伺服器當中的一種,是基於嵌入式系統而實現的web伺服器。指的是在嵌入式系統上實現的一個web伺服器,可以通過ie等去訪問,對硬體要求稍微低一點。
嵌入式WEB伺服器常見的有:Lighttpd,Shttpd,Thttpd,Boa,Mini_httpd,Appweb,Goahead
1.移植環境搭建
新建工作目錄
mkdir -p ~/Develop/webserver
如果移植Lighttpd,就在/home/wyy/Develop/webserver目錄下新建一個Lighttpd目錄
mkdir -p ~/Develop/webserver/lighttpd
2.Lighttpd移植
LibHttpd是一個開源輕量級嵌入式Web server,是提供一個專門針對高效能網站,安全、快速、相容性好並且靈活的web server環境。具有非常低的記憶體開銷,cpu佔用率低,效能好,以及豐富的模組等特點。
lighttpd 適合靜態資源類的服務,比如圖片、資原始檔、靜態HTML等等的應用,效能應該比較好,同時也適合簡單的CGI應用的場合,lighttpd可以很方便的通過fastcgi支援php。
文件:http://redmine.lighttpd.net/projects/lighttpd/wiki
2.1 下載原始碼並解壓
mkdir -p ~/Develop/webserver/lighttpd
cd ~/Develop/webserver/lighttpd
wget https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.51.tar.gz
tar xvf lighttpd-1.4.51.tar.gz
2.2 編譯配置
http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs#Documentation-Overview
cd ~/Develop/webserver/lighttpd/lighttpd-1.4.51
./configure --prefix=/home/wyy/Develop/webserver/lighttpd/web --host=arm-linux-gnueabihf --build=i686-pc-linux --disable-FEATURE --enable-shared --disable-static --disable-lfs --disable-ipv6 --without-PACKAGE --without-valgrind --without-openssl --without-kerberos5 --without-pcre --without-zlib --without-bzip2 --without-lua
2.3 編譯安裝
make -j4
make install
2.4 Lighttpd配置
安裝完成後會在安裝目錄下生成3個資料夾lib,sbin,share,需要手動再建立一些目錄
cd ~Develop/webserver/lighttpd/web
mkdir -p cache cgi-bin config log sockets upload vhosts webpages
將原始碼中doc/config目錄下的所有檔案複製到安裝目錄中config資料夾裡面
cp -a ~/Develop/webserver/lighttpd/lighttpd-1.4.51/doc/config/* ./config/
#刪除裡面的makefile檔案當然不刪除也可以不影響使用
rm -rf ./config/Makefile*
2.4.1 修改lighttpd.conf檔案
vi ./config/lighttpd.conf
將16行至20行修改為如下
var.log_root = "/home/wyy/Develop/webserver/lighttpd/web/log"
var.server_root = "/home/wyy/Develop/webserver/lighttpd/web"
var.state_dir = "/home/wyy/Develop/webserver/lighttpd/web"
var.home_dir = "/home/wyy/Develop/webserver/lighttpd/web"
var.conf_dir = "/home/wyy/Develop/webserver/lighttpd/web/config"
將61行修改為如下
var.cache_dir = server_root + "/cache"
將93行修改為如下
server.use-ipv6 = "disable"
將104和105行註釋掉,如下所示
#server.username = "lighttpd"
#server.groupname = "lighttpd"
將115行修改為如下
server.document-root = server_root + "/webpages"
將127行註釋掉,如下所示
#server.pid-file = state_dir + "/lighttpd.pid"
如果不需要檢視錯誤日誌檔案,可以將141行註釋掉
server.errorlog = log_root + "/error.log"
將152行註釋掉,如下所示
#include "conf.d/access_log.conf"
將158行註釋掉,如下所示
#include "conf.d/debug.conf"
將191行註釋掉,如下所示
#server.network-backend = "linux-sendfile"
根據系統資源設定207行和254行的數值
#max-fds必須是max-connections兩倍
server.max-fds = 256
server.max-connections = 128
將343至345行註釋掉,如下所示
#$HTTP["url"] =~ "\.pdf$" {
# server.range-requests = "disable"
#}
將408行修改為如下
server.upload-dirs = ("/home/wyy/Develop/webserver/lighttpd/web/upload")
2.4.2 修改modules.conf檔案
vi ./config/modules.conf
在43後插入**“mod_alias”**
server.modules = (
"mod_access",
"mod_alias", #加在這裡
# "mod_alias",
# "mod_auth",
# "mod_authn_file",
# "mod_evasive",
# "mod_redirect",
# "mod_rewrite",
# "mod_setenv",
# "mod_usertrack",
)
使能CGI模組,將144行的註釋符去掉
##
## plain old CGI (mod_cgi)
##
include "conf.d/cgi.conf"
2.4.3 修改conf.d資料夾中的cgi.conf檔案
vi ./config/conf.d/cgi.conf
將15至19行這一段配置修改如下
#將以下內容
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python" )
#修改為
cgi.assign = (".cgi" => "")
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl",
# ".rb" => "/usr/bin/ruby",
# ".erb" => "/usr/bin/eruby",
# ".py" => "/usr/bin/python" )
將28行的註釋符去掉,如下所示
alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
2.4.4 修改conf.d資料夾中的cgi.conf檔案
vi ./config/conf.d/dirlisting.conf
將24行的註釋掉,如下所示
##
## list of regular expressions. Files that match any of the specified
## regular expressions will be excluded from directory listings.
##
#dir-listing.exclude = ( "~$" )
由於便是去掉了pcre的支援,所以這裡將其註釋掉否則會出現以下錯誤資訊
1970-01-01 00:24:24: (server.c.1436) server started (lighttpd/1.4.51)
1970-01-01 00:24:24: (mod_dirlisting.c.300) pcre support is missing for: dir-listing.exclude , please install libpcre and the headers
1970-01-01 00:24:24: (server.c.1444) Configuration of plugins failed. Going down.
2.5 Lighttpd測試
編寫名為index.html的頁面
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>lighttpd測試</title>
</head>
<body>
<p>輕量級web伺服器lighttpd測試(for arm)</p>
<hr>
<p>hello word!</p>
</body>
</html>
將這個index.html檔案拷貝到Lighttpd安裝目錄下webpages裡
2.5.1 啟動Lighttpd伺服器
注意:部署到開發板時目錄要和開發環境的一樣,可以通過上面的配置修改路徑。
cd ~/Develop/webserver/lighttpd/web/sbin
./lighttpd -f ../config/lighttpd.conf
開啟瀏覽器就可以看到輸出的頁面了
2.5.2 關閉Lighttpd伺服器
killall lighttpd
2.6 CGI測試
編寫cgi程式
test.c
#include <stdio.h>
int main()
{
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head>\n");
printf("<title>CGI Output</title>\n");
printf("</head>\n");
printf("<body>");
printf("<h1> Hello, world. </h1>");
printf("</body>");
printf("</html>\n");
return 0;
}
編譯cgi,並將test.cgi程式拷貝到開發板的~/Develop/webserver/lighttpd/web/cgi-bin目錄下
arm-linux-gnueabihf-gcc test.c -o test.cgi
在瀏覽器中輸入地址192.168.x.x/cgi-bin/test.cgi即可訪問
3.Shttpd移植
Shttpd,開源。它是另一個輕量級的web server,具有比thttpd更豐富的功能特性,支援CGI, SSL, cookie, MD5認證, 還能嵌入(embedded)到現有的軟體裡。最有意思的是不需要配置檔案!由於shttpd可以輕鬆嵌入其他程式裡,因此shttpd是較為理想的web server開發原形,開發人員可以基於shttpd開發出自己的webserver,官方網站上稱shttpd如果使用uclibc/dielibc(libc的簡化子集)則開銷將非常非常低。
官網:https://docs.huihoo.com/shttpd/
文件:https://docs.huihoo.com/shttpd/shttpd.1.txt
3.1 下載原始碼並解壓
mkdir -p ~/Develop/webserver/Shttpd
cd ~/Develop/webserver/Shttpd
wget https://nchc.dl.sourceforge.net/project/shttpd/shttpd/1.42/shttpd-1.42.tar.gz
tar xvf shttpd-1.42.tar.gz
3.2 編譯配置
cd ~/Develop/webserver/Shttpd/shttpd-1.42
修改src/Makefile,在第29行空白處新增以下4行,如下所示
# 3. start console, go to shttpd-VERSION\src\ directory
# 4. type "nmake msvc"
# 5. go to shttpd-VERSION\examples , type "nmake msvc"
CC=arm-linux-gnueabihf-gcc
AR=arm-linux-gnueabihf-ar
CFLAGS="-DNO_SSL "
all:
@echo "make (unix|msvc|mingw|rtems)"
@echo 'Linux: "LIBS=-ldl make unix"'
@echo 'BSD: "LIBS=-lpthread make unix"'
@echo 'Solaris: "LIBS="-lpthread -lnsl -lsocket" make unix"'
3.3 編譯
LIBS="-lpthread " make unix
成功後,會產生靜態庫libshttpd.a和可執行檔案shttpd,後面會用到這個libshttpd.a檔案。
3.4 執行shttpd
#靜態頁面存放在/home/wyy/Develop/webserver/shttpd/web,可以放到任意你想放的位置,然後通過-root來之指定
./shttpd -root /home/wyy/Develop/webserver/shttpd/web -ports 80
3.5 shttpd測試
假設靜態頁面和CGI存放在/home/wyy/Develop/webserver/shttpd/web目錄下
3.5.1 靜態頁面測試
將靜態頁面放在-root指定的/home/wyy/Develop/webserver/shttpd/web目錄下,使用瀏覽器中輸入伺服器地址即可看到測試頁面。
3.5.2 使用官方例子測試shttpd
進到原始碼目錄下examples,修改example.c檔案,去掉SSL等功能,修改如下:
將第349,351,374,372,373行註釋掉。
ctx = shttpd_init(argc, argv);
//shttpd_set_option(ctx, "ssl_cert", "shttpd.pem");
shttpd_set_option(ctx, "aliases", ALIAS_URI "=" ALIAS_DIR);
//shttpd_set_option(ctx, "ports", "8080,8081s");
/* Register an index page under two URIs */
shttpd_register_uri(ctx, "/", &show_index, (void *) &data);
shttpd_register_uri(ctx, "/abc.html", &show_index, (void *) &data);
/* Register a callback on wildcard URI */
shttpd_register_uri(ctx, "/users/*/", &show_users, NULL);
/* Show how to use password protection */
shttpd_register_uri(ctx, "/secret", &show_secret, NULL);
shttpd_set_option(ctx, "protect", "/secret=passfile");
/* Show how to use stateful big data transfer */
shttpd_register_uri(ctx, "/huge", &show_huge, NULL);
/* Register URI for file upload */
shttpd_register_uri(ctx, "/post", &show_post, NULL);
/* Register SSI callbacks */
//shttpd_register_ssi_func(ctx, "true", ssi_test_true, NULL);
//shttpd_register_ssi_func(ctx, "false", ssi_test_false, NULL);
//shttpd_register_ssi_func(ctx, "print_stuff", ssi_print_stuff, NULL);
shttpd_handle_error(ctx, 404, show_404, NULL);
編譯例子
arm-linux-gnueabihf-gcc example.c -I ../src ../src/libshttpd.a -ldl -lpthread -o test
成功後,執行./test,使用瀏覽器訪問http://192.168.x.x/,可以看到輸出的介面。
3.6 CGI測試
將CGI程式放在-root指定的/home/wyy/Develop/webserver/shttpd/web目錄下,假設cgi檔名為test.cgi,在流覽器中輸入伺服器地址192.168.1.2/test.cgi,即可訪問cgi程式。(這裡成CGI程式的字尾是.cgi,但是沒有規定一定是.cgi字尾,可以設定成任意的,如test.loveyou)
編寫cgi程式
test.c
#include <stdio.h>
int main()
{
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head>\n");
printf("<title>CGI Output</title>\n");
printf("</head>\n");
printf("<body>");
printf("<h1> Hello, world. </h1>");
printf("</body>");
printf("</html>\n");
return 0;
}
編譯cgi,並將test.cgi程式拷貝到開發板的/home/wyy/Develop/webserver/shttpd/web目錄下
arm-linux-gnueabihf-gcc test.c -o test.cgi
在瀏覽器中輸入地址192.168.x.x/test.cgi即可訪問
4.Thttpd移植
是一款比較精巧的開源Web伺服器。它的初衷是提供一款簡單、小巧、易移植、快速和安全的HTTP伺服器。對於併發請求不使用fork()來派生子程序處理,而是採用多路複用(Multiplex)技術來實現。
thttpd至少和主流的web server一樣快,在高負載下更快,因為其資源佔用小的緣故。
Thttpd還有一個較為引人注目的特點:基於URL的檔案流量限制,這對於下載的流量控制而言是非常方便的。象Apache就必須使用外掛實現,效率較thttpd低。Thttp是開源的。是用C語言編寫的,使用的很多。
官網:http://www.acme.com/software/thttpd/
4.1 下載原始碼並解壓
mkdir -p ~/Develop/webserver/Thttpd
cd ~/Develop/webserver/Thttpd
wget http://www.acme.com/software/thttpd/thttpd-2.29.tar.gz
tar xvf thttpd-2.29.tar.gz
4.2 編譯配置
cd ~/Develop/webserver/Thttpd/thttpd-2.29
./configure
修改Makefile,在第50行將編譯器改為arm-linux-gnueabihf-gcc
vi Makefile
修改如下:
# You shouldn't need to edit anything below here.
CC = arm-linux-gnueabihf-gcc #修改這裡
CCOPT = -O2
在cgi-src和extras目錄中也有Makefile,修改方法和上面一樣。
4.3 編譯
make -j4
4.4 Thttpd部署
建立thttpd的工作目錄,假設目錄是/home/wyy/Develop/webserver/Thttpd/web
#thttpd工作目錄
mkdir -p /home/wyy/Develop/webserver/Thttpd/web
#頁面
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/www
#配置檔案conf
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/conf
#可執行檔案sbin
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/sbin
#log檔案目錄
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/log
#cgi-bin目錄
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/www/cgi-bin
mkdir -p /home/wyy/Develop/webserver/Thttpd/web/run
將生成的thttpd複製到/home/wyy/Develop/webserver/Thttpd/web/sbin目錄,contrib/redhat-rpm/thttpd.conf複製到/home/wyy/Develop/webserver/Thttpd/web/conf 目錄,並修改thttpd為可執行。
使用vi開啟thttpd.conf檔案,並進行配置,如下配置我們僅將“user=httpd”改為“user=root”,如果不修改會提示不存在httpd使用者,解決方法是新建一個httpd使用者sudo useradd httpd,這裡直接改為root用就無需建立新使用者了
# This section overrides defaults
dir=/home/wyy/Develop/webserver/Thttpd/web/www
nochroot # chroot
user=root# default = nobody #修改這裡
logfile=/home/wyy/Develop/webserver/Thttpd/web/log/thttpd.log
pidfile=/home/wyy/Develop/webserver/Thttpd/web/run/thttpd.pid
# This section _documents_ defaults in effect
# port=80
# nosymlink# default = !chroot
# novhost
# nocgipat
cgipat=/cgi-bin/*
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1
4.5 Thttpd測試
建立一個名為index.html,並將給檔案拷貝到開發板/home/wyy/Develop/webserver/Thttpd/web/www
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Thttpd測試</title>
</head>
<body>
<h1>Hello word!</h1>
<p>We are coming from one world, welcome here!</p>
</body>
</html>
開啟thttpd,開啟瀏覽器即可訪問
./thttpd -D -C ../conf/thttpd.conf
4.6 CGI指令碼測試
編寫測試程式
test.c
#include <stdio.h>
int main(void)
{
int i = 10;
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head><title>CGI Output</title></head>\n");
printf("<body>\n");
while(i)
printf("<h1>%d\n</h1>\n",i--);
printf("<body>\n");
printf("</html>\n");
return 0;
}
交叉編譯,拷貝cgi程式到開發板目錄/home/wyy/Develop/webserver/Thttpd/web/cgi-bin
arm-linux-gnueabihf-gcc -o test.cgi test.c
測試CGI
在瀏覽器中輸入http://192.168.x.x/cgi-bin/test.cgi
5.Boa移植
伺服器是一個小巧高效的web伺服器,是一個運行於unix或linux下的,支援CGI的、適合於嵌入式系統的單任務的http伺服器,原始碼開放、效能高。
是一種非常小巧的Web伺服器,其可執行程式碼只有大約60KB左右。作為一種單任務Web伺服器,Boa只能依次完成使用者的請求,而不會fork出新的程序來處理併發連線請求。但Boa支援CGI,能夠為CGI程式fork出一個程序來執行。Boa的設計目標是速度和安全。
文旦:http://www.boa.org/documentation/
5.1 下載原始碼並解壓
mkdir -p ~/Develop/webserver/Boa
cd ~/Develop/webserver/Boa
wget http://www.boa.org/boa-0.94.13.tar.gz
tar xvf boa-0.94.13.tar.gz
5.2 編譯配置
cd ~/Develop/webserver/Boa/boa-0.94.13/src
./configure
修改Makefile
vi Makefile
將第23行修改為
LDFLAGS = -static
將第31,32行修改為
CC = arm-linux-gnueabihf-gcc
CPP = arm-linux-gnueabihf-gcc –E
5.3 修改原始碼
5.3.1 修改boa.c檔案
將第225行程式碼註釋掉,如下
//if ( setuid ( 0 ) != - 1 ) {
// DIE ( "icky Linux kernel bug!" );
//}
5.3.2 修改compat.h檔案
修改第120行,如下
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
修改成
#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff
5.3.3 修改config.c檔案
將第266到286行程式碼註釋掉,不註釋會報錯:gethostbyname:: Resource temporarily unavailable
/*
if(!server_name)
{
struct hostent *he;
char temp_name[100];
......
perror("strdup:");
exit(1);
}
}*/
5.3.4 修改log.c檔案
註釋掉第72到74,不註釋會報錯:unable to dup2 the error log:bad file descriptor
/*if (dup2(error_log, STDERR_FILENO) == -1) {
DIE("unable to dup2 the error log");
}*/
5.4 編譯
make -j4
如果編譯出現報錯,那麼應該安裝一下兩個工具
sudo apt-get install bison
sudo apt-get install flex
去除除錯資訊
arm-linux-gnueabihf-strip boa
修改執行許可權
chmod 777 boa
5.5 Boa伺服器配置
5.5.1 Boa配置檔案解析
# 指定boa工作目錄,從該目錄載入boa.conf
# boa -c /usr/local/boa
# 監聽的埠
Port 80
# 伺服器繫結的IP地址,註釋掉表示繫結到INADDR_ANY,適配伺服器所有的IP
# Listen 192.68.0.5
# 伺服器執行的使用者和組
# User o
User 0
# Group o
Group 0
# 當伺服器發生問題時傳送報警的email地址
# ServerAdmin [email protected]
# 錯誤日誌檔案
ErrorLog /var/log/boa/error_log
# 訪問日誌檔案
AccessLog /var/log/boa/access_log
# 是否使用本地時間。如果沒註釋掉,則使用本地時間。註釋掉則使用UTC時間
# UseLocaltime
# 是否記錄CGI執行資訊
# VerboseCGILogs
# 伺服器名字
ServerName www.hello.com
# 是否啟動虛擬主機功能,即裝置可以有多個網路介面,每個介面都可以擁有一個虛擬的Web伺服器
# VirtualHost
# 非常重要,HTML文件的主目錄
DocumentRoot /var/www
# 如果收到一個使用者請求的話,在使用者主目錄後再增加的目錄名
UserDir public_html
# HTML目錄索引的檔名
DirectoryIndex index.html
# 指定用於生成目錄的程式,註釋此變數將不允許列目錄
# DirectoryMaker /usr/lib/boa/boa_indexer
# DirectoryCache: If DirectoryIndex doesn't exist, and DirectoryMaker
# has been commented out, the the on-the-fly indexing of Boa can be used
# to generate indexes of directories. Be warned that the output is
# extremely minimal and can cause delays when slow disks are used.
# Note: The DirectoryCache must be writable by the same user/group that
# Boa runs as.
# DirectoryCache /var/spool/boa/dircache
# 一個連線所允許的HTTP持續作用請求最大數目
KeepAliveMax 1000
# HTTP持續作用中伺服器在兩次請求之間等待的時間數,以秒為單位,超時將關閉連線
KeepAliveTimeout 10
# 指明mime.types檔案位置
MimeTypes /etc/mime.types
# 副檔名沒有或未知的話,使用的預設MIME型別
DefaultType text/plain
# Uncomment the next line if you want .cgi files to execute from anywhere
# AddType application/x-httpd-cgi cgi
# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Example: Redirect /bar http://elsewhere/feh/bar
# CGIPath: The value of the $PATH environment variable given to CGI progs.
CGIPath /bin:/usr/bin:/usr/local/bin
# 為路徑加上別名
Alias /doc /usr/doc
# 指明CGI指令碼的虛擬路徑對應的實際路徑
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
5.5.2 伺服器部署
從linux的etc目錄拷貝mime.types、passwd、group檔案到開發板系統的etc目錄(一般已經有passwd和group,只需拷貝mime.types),將boa拷貝到開發板的/bin目錄下,在開發板/etc目錄下建boa目錄,拷貝boa.conf到板子的/etc/boa目錄。
開發版:
mkdir -p /home/wyy/Develop/webserver/Boa
mkdir /home/wyy/Develop/webserver/Boa/www
mkdir /home/wyy/Develop/webserver/Boa/cgi-bin
mkdir /home/wyy/Develop/webserver/Boa/boa
mkdir /home/wyy/Develop/webserver/Boa/bin
mkdir /home/wyy/Develop/webserver/Boa/log
mkdir /home/wyy/Develop/webserver/Boa/doc
mkdir /home/wyy/Develop/webserver/Boa/indexer
將宿主機中的mime.types拷貝到開發板的/home/wyy/Develop/webserver/Boa/boa中,將原始碼目錄中的boa.conf拷貝到/home/wyy/Develop/webserver/Boa/boa中。將boa可執行檔案拷貝到/home/wyy/Develop/webserver/Boa/bin
修改boa.conf
vi /etc/boa/boa.conf
# 1.User的修改
User nobody
# 修改為
User 0
# 2.Group的修改
Group nogroup
# 修改為
Group 0
# 3.錯誤日誌路徑
ErrorLog /var/log/error_log
# 修改為
ErrorLog /home/wyy/Develop/webserver/Boa/log/error_log
# 4.ServerName的設定
# ServerName www.your.org.here
# 修改為
ServerName www.your.org.here
#否則會出現錯誤“gethostbyname::No such file or directory”
# 5.DoucmentRoot的修改
DoucmentRoot /var/www
# 修改為
DoucmentRoot /home/wyy/Develop/webserver/Boa/www
# 6.指定資源型別檔案
MimeTypes /etc/mime.types
# 修改為
MimeTypes /home/wyy/Develop/webserver/Boa/boa/mime.types
# 7.修改生成目錄
DirectoryMaker /usr/lib/boa/boa_indexer
# 修改為
DirectoryMaker /home/wyy/Develop/webserver/Boa/indexer
# 8.修改文件目錄
Alias /doc /usr/doc
# 修改為
Alias /doc /home/wyy/Develop/webserver/Boa/doc
# 9.ScriptAlias的修改
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
# 修改為
ScriptAlias /cgi-bin/ /home/wyy/Develop/webserver/Boa/cgi-bin/
5.6 Boa測試
在開發板上編寫一個名為index.html的靜態頁面,將該頁面拷貝到/www目錄下,使用瀏覽器輸入開發板ip即可訪問。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Boa 靜態網頁測試</title>
</head>
<body>
<h1> Welcome to Boa sever! </h1>
</body>
</html>
5.7 CGI測試
編寫cgi程式
test.c
#include <stdio.h>
int main()
{
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head>\n");
printf("<title>CGI Output</title>\n");
printf("</head>\n");
printf("<body>");
printf("<h1> Hello, world. </h1>");
printf
