httpd
一、apr 安裝
1、解壓
tar -xvf apr-1.7.0.tar.bz2
2、編譯
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --prefix=/usr/local/apr ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=yes apr_cv_tcp_nodelay_with_cork=yes ap_void_ptr_lt_long=no
參數說明
①如果不添加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
③如果不添加apr_cv_process_shared_works、apr_cv_mutex_robust_shared、apr_cv_tcp_nodelay_with_cork則會出現如下錯誤:
-
如果不寫入第一項,則會出現錯誤:
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
2.1、報錯./include/apr_want.h:94:8: error: redefinition of 'struct iovec'
解決:vi include/apr_want.h
在編譯的過程中會提示“iovec定義重復”在/apr/include目錄。修改apr_want.h文件。將
#ifndef APR_IOVEC_DEFINED
#define APR_IOVEC_DEFINED
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif /* !APR_IOVEC_DEFINED */
改為
#if 0
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif /* !APR_IOVEC_DEFINED */
2.2、報錯encoding/apr_escape.c:79:33: error: ‘test_char_table’ undeclared
tools/gen_test_char > include/private/apr_escape_test_char.h
/bin/bash: tools/gen_test_char: cannot execute binary file: Exec format error
原因:
因為gen_test_char 使用編譯工具編譯出來的,但交叉編譯出的gen_test_char這個工具在宿主機上無法使用,
所以可以先./configure 再make 將工具保存起來 在執行交叉編譯configure,再把工具cp回原位置並修改makefile 執行即解決
3、完整編譯流程
1 ./configure
2 Make
3 cp -a tools/gen_test_char ..
4 Make clean
5 ./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --prefix=/usr/local/apr ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=yes apr_cv_tcp_nodelay_with_cork=yes ap_void_ptr_lt_long=no
6 cp -a ../gen_test_char tools/
7 Vi Makefile
134 行
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
屏蔽
#OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
目的是不生成新的gen_test_char文件
8 vi include/apr_want.h 刪除第 92 行 第93 #ifndef APR_IOVEC_DEFINED 替換成#if 0
9 make && make install
二、apr-util安裝
先交叉編譯libexpat,否則會報如下錯誤
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/package/apr-util-1.6.1'
make: *** [all-recursive] Error 1
編譯過程
下載expat二進制包 [https://sourceforge.net/projects/expat/files/expat/2.2.9/expat-2.2.9.tar.xz/download]
tar -xvf expat-2.2.9.tar.xz
cd expat-2.2.9
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --prefix=/usr/local/expat
make && make install
1、編譯
./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-expat=/usr/local/expat
make && make install
如下成功:
{{uploading-image-817344.png(uploading...)}}
三、httpd安裝
注意:在對httpd進行arm交叉編譯前,需要進行一次常規編譯,執行到 make 后即可,無需執行make install。
原因:因為宿主機上無法運行使用交叉編譯鏈編譯的程序的緣故
將常規編譯在httpd安裝包生成的server文件夾拷出,留作后續使用。
tip:常規編譯及交叉編譯包不要弄混。
1、解壓
tar -xvf httpd-2.4.43.tar.gz
cd httpd-2.4.43
2、編譯
./configure --prefix=/usr/local/mawbd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc ap_cv_void_ptr_lt_long=no --enable-so --enable-cgi LDFLAGS=-lpthread
make
2.1 錯誤
①如果不添加ap_cv_void_ptr_lt_long=no選項,則會出現:
configure: error: Size of "void *" is less than size of "long"
②在執行過./configure指令后,進入httpd-2.4.3目錄下的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
保存后,將常規編譯產出的server包導入到該環境的任意位置,切記不要放置在http的下。
然后找到server中的可執行程序gen_test_char
,然后執行 ./gen_test_char > test_char.h
接下來make && make install 就不會報錯了
如果不做上面任何修改,則會出現以下錯誤:
./gen_test_char > test_char.h
/bin/sh: ./gen_test_char: cannot execute binary file
至此apache在arm上交叉編譯就完成了,可以通過file去檢測httpd