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 <stdio.h>
#include "sqlite3.h" /* orignal is <sqlite3.h> */

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s/n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("/n");
return 0;
}

int main(int argc, char **argv){
sqlite3 *db;
char *zErrMsg = 0;
int rc;

if( argc!=3 ){
fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT/n", argv[0]);
exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc ){
fprintf(stderr, "Can't open database: %s/n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s/n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
}
 
#arm-linux-gcc test.c -L.libs -lsqlite3 –static
#arm-linux-strip a.out
a.out 程序上传至终端 , 并执行
#a.out test "select * from tbl"
one = hello
two = 10
one = goodbye
two = 20
 
 
1.  http://www.apache.org/ 上下载apache_1.3.39.tar.gz,然后解压缩的一个目录,然后转到apache_1.3.39目录。
2.  使用本地的gcc编译这个版本,运行:
./ configure
make 完成后,不需要make install
3.  然后创建一个新的编译arm版本的目录,然后在那个目录下解压缩apache_1.3.39.tar.gz,转到该目录下的apache_1.3.39,运行:
 export CC="arm-linux-gcc"
./configure --prefix=/data0/apache/ --without-execstrip --enable-module=so  
 
  然后运行make 命令,这时编译会在apache_1.3.39/src/main/gen_test_char处失败,因为arm版本该程序无法在本地机器运行,你需要把前面编译的本地版本的apache_1.3.39/src/main/gen_test_char覆盖这个arm版本,然后转到arm版本的apache_1.3.39下继续make,随后编译到另一个程序apache_1.3.39/src/main/gen_uri_delims也出现相同的问题,也使用本地版本覆盖掉它,继续make,直到最后编译成功。
4. --prefix=/data0/apache / 指定了安装的目录为/data0/apache/,运行make install,所有编译好的arm版本的apache程序都安装到了/data0/apache/目录下,你把这个目录压缩后,上传至终端上,然后修改conf/httpd.conf配置文件。
5. 注意要修改conf/httpd.conf,增加ServerName www.willfar-ertu.com:80,否则在启动服务时会报一个警告 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
6 . 执行如下命令判断apache是否安装成功 http://IP:80 如果显示了apache说明页面,则说明安装成功.如果出现403的错误提示,请确认apache的目录权限是否为755,包括apache的上级目录.
 
PHP for ARM Linux
1.     http://www.php.net 上下载php-4.4.8.tar.gz,然后解压缩的一个目录,然后转到php-4.4.8目录
2. export CC=”arm-linux-gcc”
3. 修改 configure文件,将其中交叉编译错误处理注释掉,例:
#if test "$cross_compiling" = yes; then
 #    { echo "configure: error 7: can not run test program while cross compiling" 1>&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
替换为
如果不替换会在最后链接时,报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
 
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>
#
 
#AddType application/x-gzip .gz .tgz
 AddType application/x-httpd-php .php
 
12.在 /data0/apache/htdoc目录下增加index.php文件,其内容如下: <? phpinfo();?>

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模块

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值