首先去下载 lighttpd 1.4.22 记得这个版本,最新到28到版本我编译有问题
编写一个shell
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# 预先安装libc6-dev,libpcre3-dev,zlib1g-dev,libbz2-dev
cd /usr/local/src
if [ -d lighttpd-1.4.22 ] ; then
echo "lighttpd directory is already"
else
tar zxvf lighttpd-1.4.22.tar.gz
fi
cd lighttpd-1.4.22
if [ -d /opt/lighttpd1.4.22 ] ; then
make clean
fi
export CC=arm-linux-gcc
export AR=arm-linux-ar
export LD=arm-linux-ld
export RANLIB=arm-linux-ranlib
export STRIP=arm-linux-strip
if [ -d /opt/lighttpd1.4.22 ] ; then
echo "lighttpd is installed"
else
./configure -host=arm-linux -prefix=/opt/lighttpd1.4.22 --disable-FEUTARE --disable-ipv6 --disable-lfs --without-bzip2
fi
if [ -f Makefile ] ; then
make
make install
fi
然后把编译后 /opt/lighttpd1.4.22 复制到开发板 /opt/lighttpd1.4.22下
配置lighttpd.conf文件
将编译目录下doc/lighttpd.conf文件拷到AT91SAM9261 & arm-linux-2.6.20的文件系统/etc目录下,并作如下修改:
(1)、设置web服务的根目录server.document-root
server.document-root = "/srv/www/htdocs/"
改为
server.document-root = "/home/web/"
(2)、server.modules中使能"mod_cgi"和"mod_fastcgi"
server.modules = (
"mod_fastcgi",
"mod_cgi")
(3)、屏蔽URL相关语句
屏蔽以下语句,否则嵌入式这样的小系统下可能无法启动
# $HTTP["url"] =~ "\.pdf$" {
# server.range-requests = "disable"
# }
(4)、使能“.py”、“.sh” 、“.cgi”类型CGI
修改 :
cgi.assign = (".cgi" => ""
)
对于带扩展名且需要特定解析程序执行的CGI,可以指定解析程序的路径,如:
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
对于带扩展名切不需要特定解析程序就能执行的CGI,可指定解析程序为空,如:
cgi.assign = (".cgi" => "")
对于不带扩展名的CGI程序,只能通过固定路径存取了,如:
cgi.assgin = ( "/cgi-bin/mycgi" => "/usr/local/cgi/mycgi )
具体配置如下:
static-file.exclude-extensions = ( ".php", ".sh", ".pl", ".fcgi", ".py" )
#### CGI module
CGI.assign = ( ".sh" => "/bin/sh",
".py" => "/usr/python2.5.4/bin/python",
".pl" => "/usr/bin/perl",
".cgi" => "" )
(5)、禁止log功能
ARM文件系统可能不能读写,所以log相关设置用#号注释掉:
## where to send error-messages to
# server.errorlog = "/var/log/lighttpd/error.log"
#### accesslog module
# accesslog.filename = "/var/log/lighttpd/access.log"
之后启动
[root@EmbedSky sky]# /opt/lighttpd1.4.22/sbin/lighttpd -f /etc/lighttpd.conf
2015-12-07 11:32:01: (log.c.97) server started
如果要重启就先kill掉进程 呵呵