httpd 服务器在6410开发板上的移植

本文是在房老师提供文档基础上修改而成,耗费了不少心血

--------------------------------------割一个------------------------------------------------------


先总结下移植:

0、环境变量:

C_INCLUDE_PATH(for C header files)和CPLUS_INCLUDE_PATH(for C++ header files)的环境变量是指明头文件的搜索路径,此两个环境变量指明的头文件会在-I指定路径之后,系统默认路径之前进行搜索。

LIBRARY_PATH指明库搜索路径,此环境变量指明路径会在-L指定路径之后,系统默认路径之前被搜索。

例如:

  1. $C_INCLUDE_PATH=/opt/example/include  
  2. $export C_INCLUDE_PATH  
  3.   
  4. $CPLUS_INCLUDE_PATH=/opt/example/include  
  5. $export CPLUS_INCLUDE_PATH  
  6.   
  7. $LIBRARY_PATH=/opt/example/lib  
  8. $export LIBRARY_PATH 

1、没有configure的
一般手动修改Makefile,在其readme或Makefile注释都有详细说明;
2、有configure的
(1)配置项如:--xxxxxx 一般在readme都有详细说明;
(2)执行 ./configure --help 可看到具体怎么配置,可能不同的软件不同,一定要看,教训!!!!!
3、
 (1)需要make  //编译
 (2)需要make install //编译安装软件自己专有的库
 (3)这两个有时只需要一个,看README
在(移植时安装)和(拷贝到开发板时)最好保持板子和PC路径一致
-------------------------------------------------------
总结库文件路径如何告诉系统让系统能识别:
例:已经将编译好的json-c-0.9安装到/usr/local/json-c-0.9-pc/
其中的lib为库目录,include/json为.h文件目录
现在要处理库文件路径:
 
如果前面编译的库是系统运行时经常使用的,可以使用下面两种方法:
1.将lib库目录加入到ld.so.conf以便加载共享库
echo "/usr/local/json-c-0.9-pc/lib/" > /etc/ld.so.conf.d/json-c-0.9-pc.conf  加入到ld.so.conf
/sbin/ldconfig 加载共享库
2.或是加入LD_LIBRARY_PATH
两种方法皆可,方法1推荐在PC上使用,方法2已经比较过时,但是好多板子的文件系统下没有/etc/ld.so.conf.d(被裁剪了),故开发板上推荐使用方法2.
 
如果前面编译的库只是临时使用,比如只是为了后面其他软件的编译过程提供原料,那么就在后面那个软件的configure过程加入参数:
--with-extraincdir=/usr/local/json-c-0.9-pc/include --with-extralibdir=/usr/local/json-c-0.9-pc/lib/
或:
CFLAGS='-I/usr/localjson-c-0.9-pc/include -I/usr/local/bzip2/include' LDFLAGS='-L/usr/json-c-0.9-pc/lib -L/usr/local/bzip2/lib' LIBS='-ljson -lbz2'
-I 指定编译时用到的头文件的搜索路径,-L 指定编译时用到的库文件的搜索路径, -l库名 指定编译时用到的库的名称
例如:
#此例中的prefix不代表安装路径,仅仅是个符号,可以换成其他的,比如route
  1 prefix=/usr/local/sqlite-arm
  2 exec_prefix=${prefix}
  3 libdir=${exec_prefix}/lib
  4 includedir=${prefix}/include
  5 Libs = -L${libdir} -lsqlite3 -lpthread
  6 Cflags = -I${includedir}
  7  
  8 CROSS_COMPILE = arm-linux-
  9 CC = $(CROSS_COMPILE)gcc
 10 LD = $(CROSS_COMPILE)ld
 11  
 12 radiodb: radiodb.o
 #指定库
 13         $(CC) $^ $(Libs) -o $@
 14 radiodb.o: radiodb.c
 #指定头文件路径
 15         $(CC) $(Cflags) -c $^ -o $@
 16 clean:
 17         rm -rf radiodb  *.o
 
 
具体该用哪种视具体情况而定,一种出错可以用另一种。
-------------------------------------------------------
先需要移植:pcre
1、下载
http://www.pcre.org/
下载pcre-8.21.tar.gz
2、配置
./configure CC=arm-linux-gcc --host=arm-linux --prefix=/usr/local/pcre-arm/ --enable-jit --enable-utf8 --enable-unicode-properties
3、make
4、make install
/usr/local/pcre-arm/bin暂时加入PATH,否则后面步骤会报configure: error: pcre-config not found
--------------------------------------------------------
需要移植:bzip2(注意读其readme,有详细说明)
1、下载bzip2-1.0.6.tar.gz,http://bzip.org/downloads.html
2、Makefile修改
   CC=arm-linux-gcc
3、make install PREFIX=/usr/local/bzip2-arm/这步安装并产生了静态库
4、修改Makefile-libbz2_so
   CC=arm-linux-gcc
   编译成共享库
   make -f Makefile-libbz2_so//这一步是为了预备着httpd编译的时候用的着,事实证明用到了
5、产生的libbz2.so.1.0 libbz2.so.1.0.6也拷贝到/usr/local/bzip2-arm/lib
-----------------------------------------------------------
移植Lighthttpd(注意,需要安装移植到/usr/local/目录下,移植到其他地方运行时会报错,目前还不知道是什么原因)
1、下载Lighthttpd
http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.29.tar.gz
2、配置
 ./configure --help 可看到help说明,如下,一定要详细看:
--------------------------------------------------------------------------
`configure' configures lighttpd 1.4.29 to adapt to many kinds of systems.
 
Usage: ./configure [OPTION]... [VAR=VALUE]...
 
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.
 
Defaults for the options are specified in brackets.
 
Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']
 
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]
 
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
 
For better control, use the options below.
 
Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/lighttpd]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]
 
Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
 
System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]
 
Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-silent-rules          less verbose build output (undo: `make V=1')
  --disable-silent-rules         verbose build output (undo: `make V=0')
  --disable-dependency-tracking  speeds up one-time build
  --enable-dependency-tracking   do not reject slow dependency extractors
  --enable-static[=PKGS]  build static libraries [default=no]
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-lfs            Turn on Large File System (default)
  --disable-ipv6          disable IPv6 support
  --enable-extra-warnings enable extra warnings (gcc specific)
 
Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-pic              try to use only PIC/non-PIC objects [default=use
                          both]
  --with-sysroot=DIR Search for dependent libraries within DIR
                        (or the compiler's sysroot if not specified).
  --with-libev[=PATH]     Include libev support for fdevent handlers in
                          PATH/include and PATH/lib
  --with-mysql[=PATH]     Include MySQL support. PATH is the path to
                          'mysql_config'
  --with-ldap             enable LDAP support
  --with-attr             enable extended attribute support
  --with-valgrind         enable internal support for valgrind
  --with-openssl[=DIR]    Include openssl support (default no)
  --with-openssl-includes=DIR
                          OpenSSL includes
  --with-openssl-libs=DIR OpenSSL libraries
  --with-kerberos5        use Kerberos5 support with OpenSSL
  --with-pcre             Enable pcre support (default yes)
  --with-zlib             Enable zlib support for mod_compress
  --with-bzip2            Enable bzip2 support for mod_compress
  --with-fam              fam/gamin for reducing number of stat() calls
  --with-webdav-props     properties in mod_webdav
  --with-webdav-locks     locks in mod_webdav
  --with-gdbm             gdbm storage for mod_trigger_b4_dl
  --with-memcache         memcached storage for mod_trigger_b4_dl
  --with-lua              lua engine for mod_cml
 
Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  LIBEV_CFLAGS
              C compiler flags for LIBEV, overriding pkg-config
  LIBEV_LIBS  linker flags for LIBEV, overriding pkg-config
  FAM_CFLAGS  C compiler flags for FAM, overriding pkg-config
  FAM_LIBS    linker flags for FAM, overriding pkg-config
  XML_CFLAGS  C compiler flags for XML, overriding pkg-config
  XML_LIBS    linker flags for XML, overriding pkg-config
  SQLITE_CFLAGS
              C compiler flags for SQLITE, overriding pkg-config
  SQLITE_LIBS linker flags for SQLITE, overriding pkg-config
  LUA_CFLAGS  C compiler flags for LUA, overriding pkg-config
  LUA_LIBS    linker flags for LUA, overriding pkg-config
 
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
 
Report bugs to <contact@lighttpd.net>.
-------------------------------------------------------------------------------------------------
配置命令,详细意义结合以上及readme:
 
./configure CC=arm-linux-gcc --prefix=/usr/local/lighttpd-arm/ --host=arm-linux --with-pcre --with-linux-aio CFLAGS='-I/usr/local/pcre-arm/include -I/usr/local/bzip2-arm/include' LDFLAGS='-L/usr/local/pcre-arm/lib -L/usr/local/bzip2-arm/lib' LIBS='-lpcre -lbz2'
 
3、
make
make install
安装于/usr/local/lighttpd-arm/
将lighttpd-arm拷贝到开发板/usr/local
像这种生成了多个文件或者在configure时指定了路径的软件要注意安装后在pc上的路径要与在板子根文件系统上的路径一致,不然出错
4、获取依赖库:arm-linux-readelf -d lighttpd
Dynamic section at offset 0x35344 contains 27 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libpcre.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000f (RPATH)                      Library rpath: [/usr/local/pcrelib/lib]
 0x0000000c (INIT)                       0xc2ec
 0x0000000d (FINI)                       0x37594
 0x00000019 (INIT_ARRAY)                 0x45338
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0x4533c
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0x8168
 0x00000005 (STRTAB)                     0xa42c
 0x00000006 (SYMTAB)                     0x8bac
 0x0000000a (STRSZ)                      5888 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x45444
 0x00000002 (PLTRELSZ)                   1088 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0xbeac
 0x00000011 (REL)                        0xbe7c
 0x00000012 (RELSZ)                      48 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0xbe3c
 0x6fffffff (VERNEEDNUM)                 2
 0x6ffffff0 (VERSYM)                     0xbb2c
 0x00000000 (NULL)                       0x0
将动态库拷贝到根文件系统的lib目录
5、将/usr/local/下pcre-arm拷贝到开发板根文件系统的/usr/local
将/usr/local/pcre-arm/lib添加到LD_LIBRARY_PATH
 
对bzip2没有做这一步是因为bzip2仅仅在编译的时候用,而pcre在运行的时候也要用,这个在configure 时的参数可以看出。
6、拷贝配置文件
 
doc下config下的lighttpd.conf module.conf及conf.d目录拷贝到/etc/lighttpd目录下
lighttpd.conf修改
 
server.use-ipv6 = "disable"
server.network-backend = "writev" (可能不用改,运行出错了再改)
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi", ".cgi" )
var.home_dir    = "/usr/local/lighttpd-arm/sbin/lighttpd"(这个有什么用的?,谁知道的话可以告诉我。)
modules.conf修改
server.modules = (
  "mod_access",
  "mod_alias",
  "mod_auth",
#  "mod_evasive",
  "mod_redirect",
  "mod_rewrite",
  "mod_setenv",
#  "mod_usertrack",
)
include "conf.d/cgi.conf"
 
 
conf.d/cgi.conf修改
 
cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                               ".cgi" => "",
                               ".rb"  => "/usr/bin/ruby",
                               ".erb" => "/usr/bin/eruby",
                               ".py"  => "/usr/bin/python" )
                   
#说明:以上的作用是遇到某后缀的请求时调用哪个路径下的哪个程序去处理,比如浏览器栏中以“.pl”结尾,那么系统使用/usr/bin/perl去处理请求,“.cgi”不许要什么专用程序去处理,可以直接运行,所以就把路径改为了空白。   
                           
alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
$HTTP["url"] =~ "^/cgi-bin" {
   cgi.assign = ( "" => "" )
}
#说明:以上语句的作用是重定义url路径,当浏览器栏输入"IP/cgi-bin"的时候,会转到server_root + "/cgi-bin"这个路径下    
#注意在lighttpd.conf中有一句“server.document-root = server_root + "/htdocs"”意思是服务器主线文件html文件的访问路径是server_root + "/htdocs",当在浏览器栏中仅输入IP的时候会转到server_root + "/htdocs"这个目录下,“server_root”是在lighttpd.conf中定义的,是一个路径,作用相当于宏定义,为了之后定义其他路径时方便。
 
创建用户:
/etc/group增加:
lighttpd:*:51:
/etc/passwd增加:
lighttpd::15:51:Lighttpd server User:/srv/www:
#说明:Lighttpd server User 这只是与该用户相关的一个名字,可以随便起,家目录“/srv/www:”表示该用户的访问权限是/srv/www/这个目录及其下层,仅表示访问权限范围,尽量与该服务器实际需要访问的范围一致。
 
创建相关目录及文件:
mkdir /var/log/lighttpd
mkdir /srv/www/htdocs    
mkdir /srv/www/cgi-bin
touch /var/log/lighttpd/error.log
mkdir /var/run
touch  /var/run/lighttpd.pid
chown -R lighttpd:lighttpd /var/log/lighttpd
chown -R lighttpd:lighttpd /srv/www
 
7、运行
/usr/local/lighttpd-arm/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
8、测试
html放在/srv/www/htdocs
cgi放在/srv/www/cgi-bin
即可!!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值