lyl801013 发表于 2015-3-8 14:49:50

apache+sqlite+php for Arm Linux(转)

  经过几天的努力终于在arm-linux平台上搭建了apache+sqlite+php平台.
  apche与sqlite网上有不少资料,而php for arm-linux很少.为了在arm平台上安装php发了不少时间.所以将搭建过程发表在此,希望对大家有所帮助.
  Sqlite for Arm Linux安装
  1、 下载sqlite3.3.8:请到http://www.sqlite.org/download.html,将下载的代码包解开,将生成sqlite3.3.8目录
  2、 修改configure文件,将下面语句注释掉
  #if test "$cross_compiling" = "yes"; then
  # { { echo "$as_me:$LINENO:: error: unable to find a compiler for building build tools" >&5#echo "$as_me: error: unable to find a compiler for building build tools" >&2;}
  # { (exit 1); exit 1; }; }
  #fi
  . . .
  #else
  # test "$cross_compiling" = yes &&
  # { { echo "$as_me:$LINENO:: error: cannot check for file existence when cross compiling" >&5
  #echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
  # { (exit 1); exit 1; }; }
  . . .
  #else
  # test "$cross_compiling" = yes &&
  # { { echo "$as_me:$LINENO:: error: cannot check for file existence when cross compiling" >&5
  #echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
  # { (exit 1); exit 1; }; }
  3、配置
  ./configure –prefix=/data0/sqlite --disable-tcl --host=arm-linux
  4、 修改Makefile文件
  将BCC = arm-linux-gcc -g -O2改成BCC = gcc -g -O2
  5、 修改Makefile文件,将sqlite3程序以静态键接库方式编译
  先需增加libsqlite3.a的编译
  再将sqlite3$(TEXE): $(TOP)/src/shell.c .libs/libsqlite3.la sqlite3.h
  改成lite3$(TEXE): $(TOP)/src/shell.c .libs/libsqlite3.a sqlite3.h
  将 -o $@ $(TOP)/src/shell.c .libs/libsqlite3.la \
  改成 -o $@ $(TOP)/src/shell.c .libs/libsqlite3.a \
  6、 Make
  7、 #arm-linux-strip sqlite3
  8、 将sqlite3上传至终端
  9、 Sqlite3程序测试
  sqlite3 test
  ,if you see the following messages:
  SQLite version 3.3.8
  Enter ".help" for instructions
  sqlite>
  input some commands to do something,
  sqlite> create table tbl(one varchar(10),two smallint);
  sqlite> insert into tbl values('hello',10);
  sqlite> insert into tbl values('goodbye',20);
  sqlite> .quit
  10、 测试C程序
  make a 'test.c' file in 'build' directory, content as showed:   
#include   
#include "sqlite3.h" /* orignal is*/   
static int callback(void *NotUsed, int argc, char **argv, char **azColName){   
int i;   
for(i=0; i&2; exit 1; }
  #else
  4 ./configure --prefix=/data0/php --with-apxs=/data0/apache/bin/apxs --enable-pdo=shared --with-sqlite=shared--with-pdo-sqlite=shared --with-zlib --host=arm-linux --enable-track-vars --with-xml
  5. 执行./configure会报一些错误,根据错误提示,修改configure文件注释掉错误处理,直到成功
  6.修改Makefile文件,将其中
  EXTRA_LIBS = -lcrypt -l -lcrypt -lz -lm -lcrypt –lcrypt
  替换为
  EXTRA_LIBS = -lcrypt -lcrypt -lz -lresolv -lm -ldl -lnsl -lcrypt –lcrypt
  如果不替换会在最后链接时,报can not find –l -lcrypt错误
  7.make
  8.make install时会报php程序无法执行,将交叉编译好的php备份成php_arm,再将本地编译好的php替换掉交叉编译的php. 继续make install
  9.执行完make install后,会在/data0目录下生成php目录,将php-4.4.8/sapi/cli/php_arm拷贝至/data0/php/bin目录,再将php目录打包,并传至终端的/data0目录下再解压
  10.将php-4.4.8/.libs目录下的libphp4.so文件传至终端/data0/apache/libexec目录下
  11.修改/data0/apache/conf目录下的httd.conf文件如下几个地方
  在# LoadModule foo_module libexec/mod_foo.so下面增加如下语句
  LoadModule php4_module      libexec/libphp4.so
  
  DirectoryIndex index.html index.php
  
  #
  #AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php .php
  12.在/data0/apache/htdoc目录下增加index.php文件,其内容如下:
  13.如果http://ip/index.php,能看到php信息,则说明php安装成功
PHP Version 4.4.8
  System   
Linux localhost 2.4.18-rmk7-pxa1 #2 四 12月 27 12:28:52 CST 2007 armv4l
  Build Date   
Feb 3 2008 11:58:44
  Configure Command   
'./configure' '--prefix=/data0/php' '--with-apxs=/data0/apache/bin/apxs' '--enable-pdo=shared' '--with-sqlite=shared' '--with-pdo-sqlite=shared' '--with-zlib' '--host=arm-linux' '--enable-track-vars' '--with-xml'
  Server API   
Apache
  Virtual Directory Support   
disabled
  Configuration File (php.ini) Path   
/data0/php/lib
  PHP API   
20020918
  PHP Extension   
20020429
  Zend Extension   
20050606
  Debug Build   
no
  Zend Memory Manager   
enabled
  Thread Safety   
disabled
  Registered PHP Streams   
php, http, ftp, compress.zlib
                                                                              php与sqlite3结合
  先从php网站上下载php-sqlite3压缩包
  1.把压缩包,解压缩到一个目录.   
2.进入该目录,运行/data0/php/bin/phpize   
3../configure --with-php-config=/data0/php/bin/php-config --with-sqlite3=你的sqlite3安装目录   
4.make   
5.make install   
6.把生成的sqlite3.so放到php扩展目录下.   
7.在php.ini加载一下sqlite3.so模块
页: [1]
查看完整版本: apache+sqlite+php for Arm Linux(转)