原文:http://blog.youkuaiyun.com/sphone89/article/details/12915827
环境: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
2、下载并编译php-5.5.5
下载地址:http://ftp.ntu.edu.tw/php/distributions/
配置和编译:此处为最简易的版本,disable掉了所有的扩展模块;
../php-5.5.5/configure --host=arm-none-linux-gnueabi --prefix=$(pwd)/../build_php --datadir=$(pwd)/../build_php/data --enable-shared --disable-FEATURE
--enable-shared --disable-all
make && make install
使用arm-none-linux-strip将生成的php-cgi处理一下,减小空间大小
把生成的结果放到目标板
cp ./php/bin/php-cgi 目标板/opt/web/cgi-bin/
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/web/cgi-bin/php-cgi",
"max-procs" => 1,
"check-local" => "disable"
))
)
##
4、添加1个php文件到webpages路径下
test.php
<?php
phpinfo();
?>
5、
启动lighttpd服务器
#/opt/web/sbin/lighttpd -m /opt/web/lib -f /opt/web/config/lighttpd.conf
6、打开pc浏览器
输入测试:http://192.168.1.129/test.php