本文共 3289 字,大约阅读时间需要 10 分钟。
嵌入式常见的WebServer有:GoAhead,Boa,Lighttpd,Shttpd,Th ttpd,Mathopd,Minihttpd,Appweb。
Boa是一个非常小巧的Web服务器,可执行代码只有约60KB。它是一个单任务Web服务器,只能依次完成用户的请求,而不会fork出新的进程来处理并发连接请求。但Boa支持CGI,能够为CGI程序fork出一个进程来执行。Boa的设计目标是速度和安全,在其站点公布的性能测试中,Boa的性能 要好于Apache服务器。
环境:ubuntu+arm-none-linux-gnueabi-gcc
1、下载并编译lighttpd-1.4.32 ../../lighttpd-1.4.32/configure --host=arm-none-linux-gnueabi \ --prefix=$(pwd)/../../out/target/opt/web --build=i386 --enable-shared --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 make && make install 顺利编译成功后,会在./out/target/opt/web里面生成3个路径 ./out/target/opt/web$ ls lib sbin share 把生成的东西都拷贝到目标板的路径里 #sudo cp ./web/* 目标板/opt/web/ -a 2、下载并编译php-5.5.5 配置和编译:此处为最简易的版本,disable掉了所有的扩展模块; ../../php-5.5.5/configure --host=arm-none-linux-gnueabi \ --prefix=$(pwd)/../../out/target/opt/php --datadir=$(pwd)/../../out/target/opt/php/data --enable-shared --disable-FEATURE --enable-shared --disable-all make && make install $ ls php 把生成的结果放到目标板 cp ./php/bin/php-cgi 目标板/opt/web/sbin/ 3、配置lighttpd使得支持php 3.1、在/opt/web/下创建cache、cgi-bin、config、log、sockets、upload、vhosts、webpages等路径,把lighttpd-1.4.32/doc/config路径里面的conf.d lighttpd.conf modules.conf拷贝到 目标板/opt/web/config。 3.2. 修改刚复制过来的lighttpd.conf文件 1)将16行至20行修改为如下褐色加粗字体所示: var.log_root = "/opt/web/log" var.server_root = "/opt/web" var.state_dir = "/opt/web" var.home_dir = "/opt/web" var.conf_dir = "/opt/web/config" 2)将61行和93行修改为如下褐色加粗字体所示: var.cache_dir = server_root + "/cache" server.use-ipv6 = "disable" 3)将104和105行注释掉,如下所示: #server.username = "lighttpd" #server.groupname = "lighttpd" 4)将115行修改为如下褐色加粗字体所示: server.document-root = server_root + "/webpages" 5)将127行注释掉,如下所示: #server.pid-file = state_dir + "/lighttpd.pid" 6)如果不需要查看错误日志文件,可以将141行注释掉,如下所示: #server.errorlog = log_root + "/error.log" 7)将152行、158行、191行注释掉,如下所示: #include "conf.d/access_log.conf" #include "conf.d/debug.conf" #server.network-backend = "linux-sendfile" 8)根据系统资源设置207行和225行的数值,本系统的设置分别如下褐色加粗字体所示: server.max-fds = 256 server.max-connections = 128 9)将314至316行注释掉,如下所示: #$HTTP["url"] =~ "\.pdf$" { # server.range-requests = "disable" #} 10)将373行修改为如下褐色加粗字体所示: server.upload-dirs = ( "/opt/web/upload" ) 3.3. 修改刚复制过来的modules.conf文件 1)找到43行,将光标定位到逗号后面,回车,插入如下内容: "mod_alias", 2)使能fastcgi模块,将132行的注释符去掉,如下所示: include "conf.d/fastcgi.conf" 3.4. 修改刚复制过来的conf.d/fastcgi.conf文件 在server.modules += ( "mod_fastcgi" )下面添加如下: fastcgi.server = ( ".php" => ( "localhost" => ( "socket" => "/opt/web/lighttpd.player.server.socket", "bin-path" => "/opt/php/bin/php-cgi", "max-procs" => 1, "check-local" => "disable" )) ) ## 4、添加1个html文件和1个php文件到webpages路径下 index.html: <html> <head> <title>broadeng-updatepage-for-bell</title> </head> <body> <form ENCTYPE="multipart/form-data" ACTION="updatefile.php3" METHOD="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="1000"> <div align="center"><center> ????è????t: <input NAME="userfile" TYPE="file"> <input TYPE="submit" VALUE="Send File"> </center></div> </form> </body> </html> test.php <?php phpinfo(); ?> 5、 启动lighttpd服务器 cd /opt/web/sbin ./lighttpd -m /opt/web/lib -f ../config/lighttpd.conf 6、打开pc浏览器 输入测试:http://192.168.1.129/ 输入测试:http://192.168.1.129/test.php转载地址:http://ehwvi.baihongyu.com/