hello world

随笔 - 2, 文章 - 63, 评论 - 0, 引用 - 0
数据加载中……

开发板上搭建lighttpd环境

要在开发板上搭建lighttpd环境,首先要在ubuntu上搭建交叉编译环境,然后对lighttpd的源码进行编译,最后将编译好的文件和配置文件拷贝到开发板上,就可以运行了。

1、在ubuntu下搭建交叉编译环境
     1) 将开发板提供的gcc拷贝到ubuntu环境下,如我本地拷贝完后的bin目录为:
     /home/acer/source/arm-gcc/fsl-linaro-toolchain/bin/
     2) 配置ubuntu的环境变量文件:
      我的ubuntu版本是10.04,打开/etc/bash.bashrc文件,然后在文件末尾增加环境变量。

      网上通用配置都包括如下一句
      export PATH=/opt/liunx/arm-gcc/fsl-linaro-toolchain/bin:$PATH
      但是因为开发板不同,我的还要增加如下几句:
       export ARCH=arm
       export CROSS_COMPILE=/home/acer/source/arm-gcc/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi-
       配置完成后,保存文件

      3)重新加载环境变量:
       source /etc/bash.bashrc
     
      4)验证交叉编译环境,我的会输出如下提示:
       acer@ace:~/lighttpd/lighttpd-1.4.18$ arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/opt/liunx/arm-gcc/fsl-linaro-toolchain/bin/../libexec/gcc/arm-fsl-linux-gnueabi/4.6.2/lto-wrapper
Target: arm-fsl-linux-gnueabi
Configured with: /work/build/.build/src/gcc-linaro-4.6-2011.06-0/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-fsl-linux-gnueabi --prefix=/work/fsl-linaro-toolchain-2.13 --with-sysroot=/work/fsl-linaro-toolchain-2.13/arm-fsl-linux-gnueabi/multi-libs --enable-languages=c,c++ --with-pkgversion='Freescale MAD -- Linaro 2011.07 -- Built at 2011/08/10 09:20' --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --with-gmp=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-mpfr=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-mpc=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-ppl=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-cloog=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-libelf=/work/build/.build/arm-fsl-linux-gnueabi/build/static --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm -L/work/build/.build/arm-fsl-linux-gnueabi/build/static/lib -lpwl' --enable-threads=posix --enable-target-optspace --enable-plugin --enable-multilib --with-local-prefix=/work/fsl-linaro-toolchain-2.13/arm-fsl-linux-gnueabi/multi-libs --disable-nls --enable-c99 --enable-long-long --with-system-zlib
Thread model: posix
gcc version 4.6.2 20110630 (prerelease) (Freescale MAD -- Linaro 2011.07 -- Built at 2011/08/10 09:20)

至此,交叉编译环境搭建完毕

2、ubuntu上编译lighttpd
我的lighttpd版本为1.4.18,可以自己去lighttpd官网上下载。

1)配置configure命令
首先进入lighttpd安装文件夹下
cd /home/acer/lighttpd/lighttpd1.4.18
./configure --prefix=/lighttpd --host=arm-linux --build=i486-linux-gnu --disable-FEATURE -disable-ipv6 -diable-lfs
2)编译
make
3)构建
创建/lighttpd文件夹(同configure中的prefix跟的路径),然后授权,最后在lighttpd的安装文件夹下构建
sudo mkdir /lighttpd
sudo chmod 777 /lighttpd
cd /home/acer/lighttpd/lighttpd1.4.18
make install

上述三步运行完之后,在/lighttpd下会生成lib、bin、sbin、share四个文件夹,这就是要拷贝到开发板上的文件。

3、开发板,创建目录,同时拷贝文件到开发板:
1)创建根目录/lighttpd(同编译时configure命令中的prefix后跟的路径),授予权限
mkdir /lighttpd
chmod 777 /lighttpd

然后将ubuntu上/lighttpd中的四个文件夹lib、bin、sbin、share拷贝到开发板的/lighttpd下,具体什么方式,自己定吧,我们使用tftp考的的,在此不冗述。

2)创建web根目录/htdocs
mkdir /htdocs
chmod 777 /htdocs

3)创建日志保存目录/var/log/lighttpd
mkdir /var/log/lighttpd
chmod 777 /var/log/lighttpd

4、配置并拷贝配置文件到开发板
在ubuntu的lighttpd安装文件中,找到lighttpd.config文件
cd /home/acer/lighttpd/lighttpd1.4.18/doc
打开lighttpd.config,作如下修改:
server.document-root        = "/htdocs/"
server.errorlog             = "/var/log/lighttpd/error.log"
然后注释掉:
#$HTTP["url"] =~ "\.pdf$" {
#  server.range-requests = "disable"
#}
保存后,将lighttpd.config拷贝到开发板的/etc/目录下,至此,已经配置完成

5、启动lighttpd
在开发板上运行:
/lighttpd/sbin/lighttpd -f /etc/lighttpd.conf

然后将一个.html文件放到/htdocs文件夹下,访问web服务器试下吧!

参考文件:
http://www.linuxidc.com/Linux/2011-09/43619.htm
http://www.linuxidc.com/Linux/2013-06/85902.htm
http://blog.163.com/ljf_gzhu/blog/static/131553440201211522317367/

posted on 2015-03-19 11:08 听风 阅读(771) 评论(0)  编辑  收藏 所属分类: 嵌入式


只有注册用户登录后才能发表评论。


网站导航: