/********************************************************************
* busybox filesystem httpd php-5.5.31 sqlite3 webserver
* 声明:
* 本文主要是记录使用httpd、php5、sqlite3搭建php web服务器。
*
* 2016-1-24 深圳 南山平山村 曾剑锋
*******************************************************************/ 一、参考文章:
. Run busybox httpd with php
https://box.matto.nl/busyboxphp.html
. Sqlite undefined reference to `sqlite3_open' error in Netbeans C++ on Ubuntu, Integrating SQLite into Netbeans C++ Ubuntu
http://stackoverflow.com/questions/3463438/sqlite-undefined-reference-to-sqlite3-open-error-in-netbeans-c-on-ubuntu-in
. 嵌入式WEB服务器移植三部曲之PHP的移植
http://blog.csdn.net/cos_sin_tan/article/details/7734278
. Real210 编译sqlite错误:.//libsqlite3.a(sqlite3.o): In function `unixDlSym’:
http://www.jyguagua.com/?p=965
. 成功移植SQLite3到ARM Linux开发板
http://www.myir-tech.com/bbs/thread-6189-1-1.html
. ARM上linux终端操作SQLITE,退格键问题
http://www.programgo.com/article/61872541163/
. 用busybox做一个简单的文件系统
http://blog.chinaunix.net/uid-9688646-id-3346880.html
. Using SQLite3 with PHP
http://babbage.cs.qc.cuny.edu/courses/cs903/2013_02/using_sqlite3.html 二、测试busybox httpd:
. cat /www/index.html
<h1>Welcome to Tinyfs</h1>
<p>zengjf</p>
. shell命令:/usr/sbin/httpd -vv -f -h /www/
. 查看ARM板IP:
[zengjf@root www]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 1E:ED:::1A:B3
inet addr:10.0.1.52 Bcast:10.0.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (4.8 KiB) TX bytes: (3.9 KiB) [zengjf@root www]#
. PC机浏览器访问:http://10.0.1.52/
经验证获取到了正确信息,Vim里贴不上图,就不贴图了。
. shell响应如下:
[zengjf@root www]# /usr/sbin/httpd -vv -f -h /www/
10.0.1.50:: url:/
10.0.1.50:: response:
三、编译、安装、测试php-5.5.
. ./configure -host=arm-linux-gnueabihf -prefix=/usr/local/php -disable-all -enable-pdo -with-sqlite3 -with-sqlite -with-pdo-sqlite -with-zlib -without-iconv
. make
. 错误
ext/sqlite3/libsqlite/sqlite3.o: In function `unixDlError':
/home/Qt/rootfs/busybox/php/php-5.5./ext/sqlite3/libsqlite/sqlite3.c:: undefined reference to `dlerror'
ext/sqlite3/libsqlite/sqlite3.o: In function `unixDlClose':
/home/Qt/rootfs/busybox/php/php-5.5./ext/sqlite3/libsqlite/sqlite3.c:: undefined reference to `dlclose'
ext/sqlite3/libsqlite/sqlite3.o: In function `unixDlSym':
/home/Qt/rootfs/busybox/php/php-5.5./ext/sqlite3/libsqlite/sqlite3.c:: undefined reference to `dlsym'
ext/sqlite3/libsqlite/sqlite3.o: In function `unixDlOpen':
/home/Qt/rootfs/busybox/php/php-5.5./ext/sqlite3/libsqlite/sqlite3.c:: undefined reference to `dlopen'
collect2: error: ld returned exit status
make: *** [sapi/cli/php] Error
. 解决方法:
修改Makefile中的:
EXTRA_LIBS = -lcrypt -lcrypt -lrt -lz -lm -lcrypt -lcrypt
为:
EXTRA_LIBS = -lcrypt -lcrypt -lrt -lz -lm -lcrypt -lcrypt -ldl
. 效果:
end_closures.lo Zend/zend_float.lo Zend/zend_string.lo Zend/zend_signal.lo Zend/zend_generators.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lcrypt -lrt -lz -lm -lcrypt -lcrypt -ldl -o sapi/cgi/php-cgi Build complete.
Don't forget to run 'make test'.
. sudo make install
. 拷贝PC机/usr/local/php目录下文件到:<filesystem root>/usr/local/php
. 配置httpd.conf:
cat /etc/httpd.conf
*.php:/usr/local/php/bin/php-cgi
. cat /www/test.php
<?
phpinfo();
?>
. PC机浏览器访问:http://10.0.1.52/test.php
. 报错现象:
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.
For more information as to why this behaviour exists, see the manual page for CGI security.
For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.
. 解决办法:
将force-cgi-redirect设置disable。
. 查看php.ini位置:
[zengjf@root /usr/local/php/bin]# ./php-cgi -i | grep ini
<tr><td class="e">Configuration File (php.ini) Path </td><td class="v">/usr/local/php/lib </td></tr>
<tr><td class="e">Loaded Configuration File </td><td class="v">/usr/local/php/lib/php.ini </td></tr>
<tr><td class="e">Scan this dir for additional .ini files </td><td class="v">(none) </td></tr>
<tr><td class="e">Additional .ini files parsed </td><td class="v">(none) </td></tr>
<tr><td class="e">user_ini.cache_ttl</td><td class="v"></td><td class="v"></td></tr>
<tr><td class="e">user_ini.filename</td><td class="v">.user.ini</td><td class="v">.user.ini</td></tr>
<tr><td class="e">Classes </td><td class="v">AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException </td></tr>
. 配置php.ini:
cat /usr/local/php/lib/php.ini
cgi.force_redirect =
cgi.redirect_status_env ="yes";
. PC机浏览器访问:http://10.0.1.52/test.php
经验证获取到了正确信息,Vim里贴不上图,就不贴图了。
. shell响应如下:
[zengjf@root /usr/local/php/lib]# /usr/sbin/httpd -vv -f -h /www/
10.0.1.50:: url:/
10.0.1.50:: response:
10.0.1.50:: url:/test.php 四、编译、安装、测试sqlite3:
. ./configure --host=arm-linux-gnueabihf --prefix=/usr/local/sqlite
. make
. sudo make install
. 报错:
libtool: install: /usr/bin/install -c .libs/libsqlite3.a /usr/local/sqlite/lib/libsqlite3.a
libtool: install: chmod /usr/local/sqlite/lib/libsqlite3.a
libtool: install: arm-linux-gnueabihf-ranlib /usr/local/sqlite/lib/libsqlite3.a
./libtool: line : arm-linux-gnueabihf-ranlib: command not found
make[]: *** [install-libLTLIBRARIES] Error
make[]: Leaving directory `/home/Qt/rootfs/busybox/sqlite/sqlite-autoconf-'
make: *** [install-am] Error
. 解决方法:
是由于使用了sudo,导致环境变丢失,用su切换到root用户,再重新设置环境变量来解决。
. 拷贝/usr/local/sqlite中的文件到<filesystem root>下对应的目录。
. 建立软链接:ln -s /bin/sqlite3 /bin/sqlite
. 不能使用退格键(backspace):
. 错误现象:
[zengjf@root ~]# sqlite
SQLite version 3.10. -- ::
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> shw^H^H^H^H^H
. 解决方法:
终端执行shell命令:stty erase ^H
. 在ARM板上运行效果如下:
[zengjf@root ~]# sqlite
SQLite version 3.10. -- ::
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .show
echo: off
eqp: off
explain: off
headers: off
mode: list
nullvalue: ""
output: stdout
colseparator: "|"
rowseparator: "\n"
stats: off
width:
sqlite> .quit
[zengjf@root ~]#
. cat /www/teatdb.php
<?
$db = new SQLite3('my_database') or die('Unable to open database');
$query = <<<EOD
CREATE TABLE IF NOT EXISTS users (
username STRING PRIMARY KEY,
password STRING)
EOD; # 这里一定要顶格
$db->exec($query) or die('Create db failed');
$query = <<<EOD
INSERT INTO users VALUES ( 'zengjf', 'root' )
EOD; # 这里一定要顶格
$db->exec($query) or die("Unable to add user $user");
$result = $db->query('SELECT * FROM users') or die('Query failed');
while ($row = $result->fetchArray())
{
echo "User: {$row['username']}\nPasswd: {$row['password']}\n";
}
?>
. PC机浏览器访问:http://10.0.1.52/testdb.php
经验证获取到了正确信息,Vim里贴不上图,就不贴图了。
. shell响应如下:
[zengjf@root ~]#
127.0.0.1:: url:/
127.0.0.1:: response:
10.0.1.50:: url:/testdb.php
. 可能错误:
. Fatal error: Class 'SQLiteDatabase' not found in /www/testdb.php on line
. 这是由于移植的sqlite3,可能这里使用的是sqlite的接口,
使用sqlite3的接口可以避免这个错误。

busybox filesystem httpd php-5.5.31 sqlite3 webserver的更多相关文章

  1. busybox filesystem matrix-gui-2.0 undefined function json_encode()

    /******************************************************************************** * matrix-gui-2.0 u ...

  2. busybox filesystem ifup

    /******************************************************************** * busybox filesystem ifup * 声明 ...

  3. busybox filesystem udhcpc 原理

    /******************************************************************** * busybox filesystem udhcpc 原理 ...

  4. busybox filesystem ts_config: No such file or directory

    /******************************************************************** * busybox filesystem ts_config ...

  5. busybox filesystem add ldd function

    /******************************************************************** * busybox filesystem add ldd f ...

  6. Run busybox httpd with php, sqlite

    /*********************************************************************************** * Run busybox h ...

  7. 使用 linux kernel +busybox 定制linux系统

    目的: 了解linux的启动过程 主要内容: 1.grub 是启动程序的bootloader 2.linux-kernel 是linux的开源内核 3.busybox 是linux的工具集合 启动顺序 ...

  8. 交叉编译Python-2.7.13到ARM(aarch32)—— 支持sqlite3

    作者:彭东林 邮箱:pengdonglin137@163.com QQ: 405728433 环境 主机: ubuntu14.04 64bit 开发板: qemu + vexpress-a9 (参考: ...

  9. httpd在嵌入式中应用

    在启动脚本合适位置添加: httpd -h /usr/app/www/ 即开始httpd服务,并定位到/usr/app/www/ 注:busybox已支持httpd命令,所以直接用即可. busybo ...

随机推荐

  1. Java多线程——<四>让线程有返回值

    一.概述 到目前为止,我们已经能够声明并使一个线程任务运行起来了.但是遇到一个问题:现在定义的任务都没有任何返回值,那么加入我们希望一个任务运行结束后告诉我一个结果,该结果表名任务执行成功或失败,此时 ...

  2. AngularJS 基础

    1. AngularJs 是一个JS 框架,是一种基于MVC的设计模式 2. script 需引用 <script src="angular.min.js">,安装包 ...

  3. uva 757

    贪心  优先队列 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> ...

  4. sgu 138

    自己猜测了一下  按比赛次数 从大到小排  然后类似于模拟 先排胜的场次 当只剩一场 将它定义为败 #include <cstdio> #include <cstdlib> # ...

  5. CentOS 6.6安装LAMP和Subversion服务器

    目标:在CentOS 6.6上安装LAMP,并安装最新版1.8.*的Subversion服务器,和Subversion权限管理前端iF.svnadmin. 安装步骤: 安装新一些版本LAMP步骤 1. ...

  6. oracle sql 性能 优化

    目录[-] (1) 选择最有效率的表名顺序(只在基于规则的优化器中有效):ORACLE的解析器按照从右到左的顺序处理FROM子句中的表名,FROM子句中写在最后的表(基础表 driving table ...

  7. nginx模块开发(18)—日志分析

    1.日志简介 nginx日志主要有两种:访问日志和错误日志.访问日志主要记录客户端访问nginx的每一个请求,格式可以自定义:错误日志主要记录客户端访问nginx出错时的日志,格式不支持自定义.两种日 ...

  8. IOS版UC我的视频地址

    UC浏览器/Library/Application Support/offlineVideos

  9. 2016年2月---Javascript

    How to Learn JavaScript Properly 如何正确学习JavaScript Learn Intermediate and Advanced JavaScript 书籍: < ...

  10. 【memcache缓存专题(1)】memcache的介绍与应用场景

    简介 Memcached是一个高性能的分布式的内存对象缓存系统,目前全世界不少人使用这个缓存项目来构建自己大负载的网站,来分担数据库的压力,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各 ...