交叉编译apache2+php5

本文档详细介绍了如何在Fedora7 Linux主机上使用GCC 3.4.2交叉编译Apache2和PHP5,以适配MIPS架构的开发板。内容包括配置环境变量、configure参数设置、编译安装过程以及解决编译和启动过程中遇到的常见错误。通过此教程,读者可以掌握Apache和PHP的交叉编译技巧。
摘要由CSDN通过智能技术生成
编译环境: 1.linux 主机:fedora7 2.开发板体系结构: mips 3.交叉编译器:gcc.3.4.2 4.交叉编译器目录:/opt/gcc342 5.软件版本:httpd-2.2.13.tar.gz apach2编译和安装: 1.configure CC=/opt/gcc342/bin/mipsel-linux-gcc CPP=/opt/gcc342/bin/mipsel-linux-cpp LD=/opt/gcc342/bin/mipsel-linux-ld AR=/opt/gcc342/bin/mipsel-linux-ar OBJDUMP=/opt/gcc342/bin/mipsel-linux-objdump AS=/opt/gcc342/bin/mipsel-linux-as STRIP=/opt/gcc342/bin/mipsel-linux-strip ./configure --host=mipsel-linux --target=mipsel-linux --build=i686-pc-linux-gnu --prefix=/uer/local/apache2 --with-program-name=apache2 --enable-module=so --enable-module=rewrite --enable-shared=max 在上面命令中: 1)交叉编译器的一些环境变量的设置:CC=/opt/gcc342/bin/mipsel-linux-gcc CPP=/opt/gcc342/bin/mipsel-linux-cpp LD=/opt/gcc342/bin/mipsel-linux-ld AR=/opt/gcc342/bin/mipsel-linux-ar OBJDUMP=/opt/gcc342/bin/mipsel-linux-objdump AS=/opt/gcc342/bin/mipsel-linux-as STRIP=/opt/gcc342/bin/mipsel-linux-strip ./conf 是对交叉编译器的一些环境变量的设置。 2)交叉编译的设置:--host=mipsel-linux --target=mipsel-linux --build=i686-pc-linux-gnu; --host = 软件在什么平台下运行,(你的开发板的系统)host= 架构-厂商-内核-标准库(mipsel-linux 表示 mips架构,unknow厂商,linux内核,gnu glibc 标准库。) --target = 软件为什么平台服务 --build = 软件在什么平台下编译(你编译目标文件的系统) 3)apache2配置: --with-program-name=apache2 更改生成的文件名,默认为httpd。 --enable-module=so 用来提DSO支持的apache核心模块,这个比较重要,以便以后安装动态模块,后面的php5就是安装的动态模块 。 --enable-module=rewrite rewrite模块则是用来实现地址重写的模块,由于rewrite模块需要DBM支持,如果在初次安装时没有编译进apache,以后需要用到时需要重新编译整个apache才可以实现。为此除非你可以确定以后不会用到rewrite模块,否则还是建议你在第一次编译的时候把rewrite模块编译好。 --enable-shared=max 这个参数的作用时编译apache时,把除了so以外的所有apache的标准模块都编译成DSO模块。而不是编译进apache核心内。 2.编译并安装 make; make install; 3.将/uer/local/apache2目录拷贝到目标板的文件系统目录下,去处没用的文件。其实文件都是有用的,只是目标板太小,只好删掉。 保留bin/apache2 conf/ module/ lib/ htdocs/文件就可以了,另外看看conf/apache2.conf中的设置是不是想要的。 4. 在目标板上启动 /uer/local/apache2/bin/apache -k start 5.在浏览器中输入本地地址,出现“it work !”,说明配置成功。 6.出现的错误: 1)./configure过程中,出现configure: error: cannot check for file existence when cross compiling等,具体原因没找,应该是交叉编译导致的。 解决:在相应目录下找到出错的地方,去掉{ (exit 1); exit 1; };我的问题一般出现在srclib/apr/configure 2)编译: a. ./include/apr_want.h:93: error: redefinition of `struct iovec' 解决:在 srclib/apr/include/apr_want.h中,注掉struct iovec b. ./dftables: cannot execute binary file 解决:因为交叉编译出的文件不能在编译的主机上执行,所以编译一个本地版本的dftables文件覆盖srclib/pcre/dftables c. ./gen_test_char: cannot execute binary file 同上 d. undefined reference to `pthread_sigmask' 解决:在build/config_var.mk里AR_LIBS变量加-lpthread 3)启动 a. 找不到文件之类 解决:在/usr/local/apache2/conf/apache2.conf中找设置的路径是否正确,或文件是否存在。 b. apache2: bad user name daemon 解决:执行adduser daemon c."apache2: apr_sockaddr_info_get() failed for (none) apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName" 将/usr/local/apache2/conf/apache2.conf文件中的#ServerName www.example.com:80替换为ServerName localhost:80 d.“(125)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down" 80端口正在使用,说明已经有httpd了 PHP5的编译和安装: 1.configue CC=/opt/gcc342/bin/mipsel-linux-gcc CPP=/opt/gcc342/bin/mipsel-linux-cpp LD=/opt/gcc342/bin/mipsel-linux-ld AR=/opt/gcc342/bin/mipsel-linux-ar OBJDUMP=/opt/gcc342/bin/mipsel-linux-objdump AS=/opt/gcc342/bin/mipsel-linux-as STRIP=/opt/gcc342/bin/mipsel-linux-strip ./configure --host=mipsel-linux --target=mipsel-linux --build=i686-pc-linux-gnu --prefix=/uer/local/PHP5 --without-iconv --disable-all --with-apxs2=/usr/local/apache2/bin/apxs --with-apxs2=/usr/local/apache2/bin/apxs 表示php5 为 Apache 共享模块安装 2.编译并安装 make; make install; 如果安装成动态库,只要将libphp5.so拷贝到/usr/local/apache2/modules就可以了,如果用cli或cgi模式,可能还需要php和php-cgi 3.修改 /usr/local/apache2/conf/apache2.conf文件 在# LoadModule foo_module modules/mod_foo.so后添加 LoadModule php5_module modules/libphp5.so 在 中添加 AddType application/x-httpd-php .php 4.在htdocs/下添加index.php,输入 5. 重新启动apache2,它将支持vphp 6.在浏览器查看index.php 7.出现的错误: 1)error: impossible constraint in `asm' 交叉编译环境错误,将include头设置为主机路径(如-I/usr/include),应该是交叉编译器的头(如-I/opt/gcc342/include);用--with-iconv=shared,/opt/gcc342/ 2)undefined reference to `php_load_extension' 是在 configure时,如果为交叉编译,她将dlopen设置为no found,只须将found=no去掉。 3)出现Syntax error on line 53 of /usr/local/apache2/conf/apache2.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: File not found a./usr/local/apache2/conf/apache2.conf中 LoadModule php5_module modules/libphp5.so目录路径不对 b.由2)导致的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值