基于loongson1b开发板(mips架构)移植apache+sqlite3+php5
环境 编译平台: Ubuntu12.04 交叉工具链: gcc-3.4.6 一、移植 Sqlite 解压 Sqlite-3.6.20.tar.gz 到工具目录下: tarzxfSqlite-3.6.20.tar.gz-C/home/xxx/tools 进入 sqlite-3.6.20 目录中: cdsqlite-3.6.20 1 ): ./configure--host=mipsel-linux( 指定
环境
编译平台:Ubuntu12.04
交叉工具链:gcc-3.4.6
一、移植Sqlite
解压Sqlite-3.6.20.tar.gz 到工具目录下:tar zxf Sqlite-3.6.20.tar.gz -C /home/xxx/tools
进入sqlite-3.6.20目录中:cd sqlite-3.6.20
1):./configure --host=mipsel-linux(指定交叉编译工具链) --prefix=/opt/mispel-linux-sqlite
2) make
3) make install
在执行make中会出现下面错误:
libtool: link: mipsel-linux-gcc -shared .libs/tclsqlite.o -Wl,-rpath -Wl,/opt/sqlite-3.6.20-embedded/.libs -Wl,-rpath -Wl,/opt/mipsel-linux-sqlite/lib ./.libs/libsqlite3.so -L/opt/tcl8.5.15/unix -ltclstub8.5 -lpthread -Wl,-soname -Wl,libtclsqlite3.so -o .libs/libtclsqlite3.so/opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/bin/ld: skipping incompatible /opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/lib/libtclstub8.5.a when searching for -ltclstub8.5/opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/bin/ld: cannot find -ltclstub8.5collect2: ld returned 1 exit statusmake: *** [libtclsqlite3.la] 错误 1
出现:skipping incompatible 一般是不同处理器架构引用了不属于自己处理器架构的库,
上面出现的情况,就是mipsel架构的引用了x86架构的库 libtclstub8.5。
所以要源码交叉编译tclsh才能解决上述问题。
解决方法:解压tcl8.5.15-src.tar.gz,并进入源码文件夹tcl8.5.15
执行:
1)./configure --host=mipsel-linux --prefix=/opt/mipsel-linux-tclsh
2) make
3) make install
但在 ./configure --host=mipsel-linux --prefix=/opt/mipsel-linux-tclsh
过程中会出现以下错误:
fixstrtod.o: In function `fixstrtod':fixstrtod.c:(.text+0x0): multiple definition of `fixstrtod'strtod.o:strtod.c:(.text+0x0): first defined herecollect2:
ld returned 1 exit statusmake: *** [libtcl8.5.so] 错误 1
执行下面语句:
[root@CaM/opt/tcl-embedded/unix 11:45]#export ac_cv_func_strtod=yes
[root@CaM/opt/tcl-embedded/unix 11:46]#export tcl_cv_strtod_buggy=1
就可以解决了。
编译安装完成后,在mipsel-linux-sqlite目录下分别生成bin、include和lib目录。
将bin/sqlite3与lib/libsqlite3.so.0.8.6分别拷至文件系统/bin目录与/lib目录下,
并将libsqlite3.so.0.8.6更名为libsqlite3.so.0完成移植。
二、移植apache
$ su (切换到root用户)
1. 本机编译
$ cd /usr/local/apache-pc/apache_1.3.39
$ ./configure
错误提示:
Configuring for Apache, Version 1.3.39
+ Warning: Your ‘echo’ command is slightly broken.
+ It interprets escape sequences per default. We already
+ tried ‘echo -E’ but had no real success. If errors occur
+ please set the SEO variable in ‘configure’ manually to
+ the required ‘echo’ options, i.e. those which force your
+ ‘echo’ to not interpret escape sequences per default.
+ using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Syntax error — The configuration file is used only to
define the list of included modules or to set Makefile in src
options or Configure rules, and I don’t see that at all:
`$(SRCDIR)/apaci`
default
default
no
no
no
yes
no
default
no
default
default
解决:
这是由于某些shell脚本文件使用了错误的interpreter,使用下面的命令就可以解决。
# rm -f /bin/sh
# ln -s /bin/bash /bin/sh
$ make
错误提示:
解决:
将提示的c文件中冲突的函数另改别名:如getline 改成get_line,总共有三个c文件要改。
执行完make后就完成本机编译了,生成了我们需要使用的编译工具。
、2. 交叉编译
(注意交叉工具链的环境)
$ cd /usr/local/apache-mipsel/apache_1.3.39
$ CC=mipsel-linux-gcc ./configure --prefix=/usr/local/apache-php/apache --enable-module=so
接着如下修改:
cp /usr/local/apache-pc/apache-1.3.39/src/main/gen_test_char /usr/local/apache-pc/apache-1.3.39/src/main/gen_uri_delims /usr/local/apache-mipsel/apache-1.3.39/src/main/
$ make
错误提示:
解决:
$ cp /usr/local/apache-pc/apache_1.3.39/src/main/gen_test_char /usr/local/apache-pc/apache_1.3.39/src/main/gen_uri_delims /usr/local/apache-mipsel/apache_1.3.39/src/main/
$ make install
如图所示,则安装成功
查看是否为交叉编译文件
$ file /usr/local/apache-php/apache/bin/httpd
三、移植PHP
1. 本地编译php
$ cd /usr/local/apache-pc/php-5.2.0
$ ./configure
错误提示 :
解决 :
sudo apt-get install flex
错误提示2 :
解决 :
sudo apt-get install libxml2-dev
$ make
2. 交叉编译
安装zlib-1.2.3
$ cd /usr/local/apache-mipsel/zlib-1.2.3
$ CC=mipsel-linux-gcc ./configure --prefix=/usr/local/apache-php/zlib
$ make
$ make install
$ cd /usr/local/apache-mipsel/php-5.2.0
$ CC=mipsel-linux-gcc ./configure --host=mipsel-linux
--prefix=/usr/local/apache-php/php --with-apxs=/usr/local/apache-php/apache/bin/apxs --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared --with-zlib --with-zlib-dir=/usr/local/apache-php/zlib --without-iconv
错误提示1:
解决:
打开脚本/usr/local/apache-mipsel/php-5.2.0/configure搜索“$APXS -q
CFLAGS >/dev/null 2>&1”进行如下代码的注释。
错误提示2:
解决 :
安装libxml2-2.6.11
$ cd libxml2-2.6.11
$ CC=mipsel-linux-gcc ./configure --host=mipsel-linux --prefix=/usr/local/apache-php/zlib
$ make
$ make install
./configure后
首先修改php的Makefile在开始出添加LDFLAGS += -ldl ,这里是为了链接dlopen库
然后修改main/php.h 在开始处添加#define HAVE_LIBDL 1 ,这个宏是为了交叉编译时强制使用dlopen。
紧接着修改ext/standard/dl.c 这段代码中添加#include
件。
#if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H
#include
#include
#include
最后修改 sapi/apache/php_apache_http.h
#include "httpd.h"
#include "http_config.h"
# include "ap_compat.h"
# include "compat.h"
#include "http_core.h"
#include "http_main.h"
#include "http_protocol.h"
#include "http_request.h"
#include "http_log.h"
#include "util_script.h"
将其修改为#include "/usr/local/apache-php/apache/include/httpd.h"这个路径(这些头文件的目录)
# make (时间有点长,去喝杯水休息一下吧0﹏0!!)
错误提示1:
解决:
修改mod_php5.c中23行错误头文件加上/usr/local/apache-arm11/apache/include路径
错误提示2 :
解决:
$ cp /opt/gcc-3.4.6-2f/lib/libxml2.so /us r/lib/i386-linux-gnu/
错误提示3: :
解决 :
暂时不知道哪里出了问题,只能注释了其中的代码
$ make install
错误提示 1 :
解决 :
$mv /usr/local/apache-php/apche/bin/httpd /usr/local/apache-php/apache/bin/httpd_backup
$ cp /usr/local/apache-pc/apache/bin/http /usr/local/apache-php/apache/bin/httpd
错误提示2 :
解决 :
$mv /usr/local/apache-mipsel/php-5.2.0/sapi/cli/php /usr/local/apache-mipsel/php-5.2.0/sapi/cli/php_backup
$ cp /usr/local/apache-pc/php-5.2.0/sapi/cli/php /usr/local/apache-mipsel/php-5.2.0/sapi/cli/
不出意外应该成功了,可以去/usr/local/apache-php/php/看下是否有目录
把原来的mips版的php、httpd还原回去 :
cp /usr/local/apache-mips/php-5.2.0/scpi/cli/php_backup /usr/local/apache-php/php/bin/
cp /usr/local/apache-mips/apache/bin/httpd_backup /usr/local/apache-php/apache/bin/httpd
四、配置httpd.conf和php.ini
l 修改httpd.conf
$ vim /usr/local/apache-php/apache/conf/httpd.conf 添加红色部分
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
DirectoryIndex index.html
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.phtml
#
# AccessFileName: The name of the file to look for in each directory
# for access control information.
#
AccessFileName .htaccess
...
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache-php/apache/cgi-bin/"
ScriptAlias /php5/ "/usr/local/apache-php/php/bin/"
#
# "/usr/local/apache-php/apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
...
#
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
AddType application/x-tar .tgz
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have nothing
l 修改php.ini
$ cp /usr/local/apache-mips/php-5.2.0/php.ini-dist /usr/local/apache-php/php/lib/
$ mv /usr/local/apache-php/lib/php.ini-dist /usr/local/apache-php/lib/php.int
$ vim /usr/local/apache-php/lib/php.int
; to possible security problems, if the code is not very well thought of.
register_globals = On
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
; and friends. If you're not using them, it's recommended to turn them off,
五、移植至loongson1B
ps进过九九八十一难终于可以烧进板啦
1、打包apache和php
# tar cjf apache-php.tar.bz2 apache-php
2、经nfs共享至开发板
3、开发板建立/usr/local/
4、解压至/usr/local/ :与宿主机一致
5、进入/usr/local/apache-php/apache/bin
# ./apachectl start
其中需要注意,因为Aapche不支持root用户,所以需要确认Linux文件系统中有nobody组和nogroup组。
在/etc添加两个用户
vi /etc/passwd :
root::0:0:root:/:/bin/bash
nobody::65534:65533:nobody:/:/bin/bash
vi /etc/group :
body::65533:
nogroup::65534:nobody
root::0:
users::100:
正常启动会弹出
若有其他问题goole、度娘一下,都是常见问题
6、打开浏览器输入http://ip:8080就能看见apache测试画面啦
7、后面加程序名就能运行程序:http://ip:8080/test.php
至此,搭建lasp环境完成...
上一篇: mysql distinct的妙用
下一篇: 网站后台管理的密码忘了如何找回