Apache2.4.3编译移植
来源:互联网 发布:ubuntu node 升级 编辑:程序博客网 时间:2024/05/16 14:55
Apache编译
需要的源码:pcre-8.31.tar.gz
apr-1.4.6.tar.gz
apr-util-1.4.1.tar.gz
httpd-2.4.3.tar.gz
说明:1,编译httpd之前需要先编译好pcre、apr和apr-util,因为在编译httpd时需要用到这三个编译好的文件。
2, 这四个源码分别需要编译两次,以生成x86和arm两个不同的平台文件。最终目的是为了移植到arm开发板上,所以先编译好httpd_pc,然后再编译httpd_arm,在编译httpd_arm时需要用到httpd_pc/server/gen_test_char这个可执行文件(文件类型属于x86平台)。
1.1.1安装pcre
tar –zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure -–prefix=/usr/local/usr/pcre
make
make install
1.1.2安装apr
tar –zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure –-prefix=/usr/local/usr/apr
make
make install
1.1.3安装apr-util
tar –zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure -–prefix=/usr/local/usr/apr-util –-with-apr=/usr/local/usr/apr
make
make install
1.1.4 安装httpd_pc
tar –zxvf httpd-2.4.3.tar.gz
解压后的文件夹名更改为httpd_pc
cdhttpd_pc
./configure -–prefix=/usr/local/usr/apache–-with-pcre=/usr/local/usr/pcre –-with-apr=/usr/local/usr/apr –-with-apr-util=/usr/local/usr/apr-util
make
*可以不make install ,因为httpd_arm在./configure时只需要用到httpd_pc/server文件夹下的gen_test_char,而此文件是在make时产生。
注:以上编译的文件类型为x86平台的,下面是arm平台。
1.2.1 安装pcre
cd pcre-8.31
./configure -–prefix=/usr/local/pcre –-host=arm-none-linux-gnueabi
make
make install
1.2.2安装apr
cd apr-1.4.6
./configure –-prefix=/usr/local/apr–-host=arm-none-linux-gnueabi ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes ac_cv_sizeof_struct_iovec=8 --cache=arm-linux.cache
make
make install
这里简要说明一下如果不添加某些选项会出现的错误提示及一些需要特别注意的地方(这里按照我所记录的错误出现的顺序说明,而不是按上面选项的顺序):
①如果不添加ac_cv_file__dev_zero=yes(注意file和dev之间是两个下划线),则会出现:
check for /dev/zero... configure:error:cannot check for file existence when cross compile
的错误,如下图:
②如果不添加ac_cv_func_setpgrp_void=yes,则会出现:
checking whether setpgrp takes no argument... configure: error: cannot check setpgrp when cross compiling
的错误,如下图:
③选项--cache=arm-linux.cache中,arm-linux.cache为自己建立编写的文件(在编译过程中内容会被修改),在建立时需要自己写入如下内容:
apr_cv_process_shared_works=yes
apr_cv_mutex_robust_shared=yes
如果不写入第一项,则会出现:
checking for working PROCESS_SHARED locks... configure:error: in `.../apr-1.4.6':
configure:error: cannot run test program while cross compiling
See `config.log' for more details
的错误,如下图:
如果不写入第二项,则会出现:
checking for robust cross-process mutex support... configure: error: in `.../apr-1.4.6':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
的错误,如下图:
这些错误产生的原因在于这里在configure运行配置的过程中要运行几个测试程序来检验一些配置(个人理解),但在此处指定了编译时采用的编译器是交叉编译链,这几个测试程序都是经过交叉编译链编译产生的,而在宿主机系统上无法运行这些程序,因此只好自己手动指定这些检测程序最后运行的结果。
在以后为开发板配置软件包时遇到这种错误:configure:error:cannot run test program while cross compiling,应该都可以通过这种方法解决。
那么如果查找出这些表示结果的变量呢?只要在configure文件中搜寻这些错误的关键字即可,如这里的第一个项,我们可以搜寻:working PROCESS_SHARED locks,然后在configure文件中可以锁定到如下代码段:
...
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working PROCESS_SHARED locks" >&5
$as_echo_n "checking for working PROCESS_SHARED locks... " >&6; }
if ${apr_cv_process_shared_works+:} false; then :
$as_echo_n "(cached) " >&6
else
...
这里可以看出变量apr_cv_process_shared_works便是与这个程序运行结果关联的变量。
④如果不添加ac_cv_sizeof_struct_iovec=8选项,则会在使用make指令时出现:
./include/apr_want.h:95: error: redefinition of 'struct iovec'
make[1]: *** [passwd/apr_getpass.lo] 错误 1
的错误,如下图:
⑤在添加了ac_cv_sizeof_struct_iovec=8选项后,还需要对configure文件进行一下修改,搜索apr_ssize_t可以定位到下面一段代码:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_ssize_t" >&5
$as_echo_n "checking which format to use for apr_ssize_t... " >&6; }
if test -n "$ssize_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$ssize_t_fmt" >&5
$as_echo "%$ssize_t_fmt" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
ssize_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
ssize_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_ssize_t" "$LINENO" 5
fi
将中间添加一段代码(红色标注),修改为:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_ssize_t" >&5
$as_echo_n "checking which format to use for apr_ssize_t... " >&6; }
if test -n "$ssize_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$ssize_t_fmt" >&5
$as_echo "%$ssize_t_fmt" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
ssize_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
ssize_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long_long";then
ssize_t_fmt="lld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %lld" >&5
$as_echo "%lld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_ssize_t" "$LINENO" 5
fi
搜索apr_size_t可以定位到下面一段代码:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_size_t" >&5
$as_echo_n "checking which format to use for apr_size_t... " >&6; }
if test -n "$size_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$size_t_fmt" >&5
$as_echo "%$size_t_fmt" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
size_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
size_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_size_t" "$LINENO" 5
fi
将中间添加一段代码(红色标注),修改为:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which format to use for apr_size_t" >&5
$as_echo_n "checking which format to use for apr_size_t... " >&6; }
if test -n "$size_t_fmt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %$size_t_fmt" >&5
$as_echo "%$size_t_fmt" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
size_t_fmt="d"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %d" >&5
$as_echo "%d" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
size_t_fmt="ld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %ld" >&5
$as_echo "%ld" >&6; }
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long_long"; then
size_t_fmt="lld"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: %lld" >&5
$as_echo "%lld" >&6; }
else
as_fn_error $? "could not determine the proper format for apr_size_t" "$LINENO" 5
fi
如果什么修改也不做,则会出现:
checking which format to use for apr_ssize_t... configure:error:could not determine the proper format for apr_ssize_t
的错误,如下图:
如果只做了第一个修改,则会出现:
checking which format to use for apr_size_t... configure:error:could not determine the proper format for apr_size_t
的错误,如下图:
这是apr源代码包本身有的bug,这样修改后,在最后编译httpd时,会出现一些warning,大概意思是说参数类型为pid_t的地方,出现的参数类型为long long,但pid_t的类型本身就是unsigned int,因此应该是没有问题的。
1.2.3安装apr-util
cd apr-util-1.4.1
./configure -–prefix=/usr/local/apr-util –-with-apr=/usr/local/apr --host=arm-none-linux-gnueabi
make
make install
1.2.4 安装httpd_arm
tar –zxvf httpd-2.4.3.tar.gz
解压后的文件夹名更改为httpd_arm
cdhttpd_arm
./configure -–prefix=/usr/apache–-with-pcre=/usr/local/pcre –-with-apr=/usr/local/ apr –-with-apr-util=/usr/local/apr-util--host=arm-none-linux-gnueabi ap_cv_void_ptr_lt_long=no --enable-so --enable-cgi LDFLAGS=-lpthread --with-mpm=prefork
在编译过程中要注意以下几点:
①如果不添加ap_cv_void_ptr_lt_long=no选项,则会出现:
configure: error: Size of "void *" is less than size of "long"
的错误,如下图:
②执行make命令前,到为开发板编译httpd的httpd_arm目录下的server目录中,修改一下其中的Makefile文件,找到如下行:
test_char.h: gen_test_char
./gen_test_char > test_char.h
修改为
test_char.h: gen_test_char
#./gen_test_char > test_char.h
/root/httpd_pc/server/gen_test_char > test_char.h
其中这里的路径为httpd_pc文件夹路径。
如果不做上面任何修改,则会出现以下错误:
./gen_test_char > test_char.h
/bin/bash: ./gen_test_char: 无法执行二进制文件
原因也是因为宿主机(x86)上无法运行使用交叉编译链编译的程序(arm)的缘故。
如果只修改为:
test_char.h: gen_test_char
#./gen_test_char > test_char.h
而在宿主机上不编译一次httpd,则会出现以下错误:
util.c: In function 'ap_find_token':
util.c:1434: error: 'test_char_table' undeclared (first use in this function)
util.c:1434: error: (Each undeclared identifier is reported only once
util.c:1434: error: for each function it appears in.)
。。。。。。。。
可见gen_test_char > test_char.h这条语句是为了生成一些宏定义或者全局变量到test_char.h这个头文件中去,而里面这些宏定义和全局变量在httpd_arm进行make时使用到。
③如果不添加--with-mpm=prefork选项,则在启动httpd服务器时会出现闪退,无法正常启动。
然后接着上面未完成的步骤,
make
make install
二,移植到开发板及复制共享库
1,将httpd_arm编译好的/usr/apache文件夹拷贝到开发板/usr/目录下,为减少占用资源,可以将manual目录删掉。
2,复制一些共享库到开发板文件系统的/lib目录下,否则会启动不了httpd服务器,像以下错误:
①error while loading shared libraries: libpcre.so.1:cannot open shared object file:No such file for directory
解决方法:cp /usr/local/pcre/lib/libpcre.so* /lib
②error while loading shared libraries: libaprutil-1.so.0:cannot open shared object file:No such file for directory
解决方法:cp /usr/local/apr-util/lib/libaprutil-1.so* /lib
③error while loading shared libraries: libexpat.so.0:cannot open shared object file:No such file for directory
解决方法:cp /usr/local/apr-util/lib/libexpat.so* /lib
④error while loading shared libraries: libapr-1.so.0:cannot open shared object file:No such file for directory
解决方法:cp /usr/local/apr/lib/libapr-1.so* /lib
三,配置httpd.conf
1,apache拒绝使用root用户运行。所以你需要增加一个用户和用户组,我们可以使用用户名和用户组名分别为nobody和nogroup。没有的话,就在/etc/passwd和/etc/group两个文件中添加。这样我们就在httpd.conf中的用户和组修改为nobody和nogroup,如图
2,默认情况下ServerName这一栏是被屏蔽了的,启动服务器时会出现如下错误:
解决方法:启用ServerName,并进行修改,如下
3,如果执行cgi程序时在网页上出现乱码信息,则说明没有添加cgi_module(默认情况下是没有添加)。
解决方法:添加这个模块,并且重启httpd如图
如果添加了模块还是乱码,检查modules目录下是否有mod_cgi.so,没有的话那就是问题所在。我们现在来创建mod_cgi.so:回到宿主机/root/httpd_arm/modules/generators目录下输入/usr/apache/bin/apxs –i –a –c mod_cgi.c ,这样就编译好了在/usr/apache/modules目录下,将其拷贝到开发板相应的目录下。
- Apache2.4.3编译移植
- 移植apache2 ARM版 - 交叉编译apache2
- 移植apache2 ARM版 - 交叉编译pcre-8.33
- 移植apache2 ARM版 - 交叉编译apr-1.4.8
- 移植apache2 ARM版 - 交叉编译apr-util
- 编译Apache2
- Apache2.4.12移植
- apache2.2.22 嵌入式移植步骤,
- 交叉编译apache2+php5
- 编译安装 apache2.4.12
- CentOS Apache2.4 编译
- Apache2.4编译步骤
- apache2.4.25编译
- apache2.4.17 编译安装
- linux apache2 编译problems
- 编译安装apache2.4
- centos6.3编译安装Apache2.4.3+PHP5.4.8+Mysql5.5.8
- apache2常用编译参数解释
- 手势和UI控件之间冲突的解决方法(比如UITapGesture和UIButton冲突,UIPanGesture和UISlider冲突)
- hdu 1081 (dp_区间dp)
- 程序员如何像写代码一样找女朋友
- POJ-2421 最小生成树 算法复习计划
- 使用fedora 20
- Apache2.4.3编译移植
- POJ1144-Network(割顶模板题)
- hdu-4857-逃生-拓扑排序
- wifi详解(二)
- Linux rpm 命令参数使用详解[介绍和应用]
- ios url转义
- 1528. Least Common Multiple
- java菜鸟问题贴
- Android的按钮单击事件及监听器的实现方式