PHP With SQLite On Digi Embedded Linux

3y ago
53 Views
3 Downloads
878.48 KB
15 Pages
Last View : 3d ago
Last Download : 3m ago
Upload by : Callan Shouse
Transcription

PHP with SQLite on Digi Embedded LinuxSQLite 2.8.17 supported with sql .() APISQLite 3.x support via PDO

PHP with Digi Embedded LinuxDocument HistoryDateVersion Change Description10/14/2009 V1.0Initial entry/outline10/16/2009 V1.1Switched back to compiling php-5.2.1111/09/2009 V1.2Integrated SQlite support, tested on CC9M244306/01/2010 V1.3Retested with php-5.2.13 DEL5.2 toolchain and pdo-sqlite forsqlite3 support on CC9P9215Table of ContentsDocument History . 2Table of Contents . 21Problem Description . 22Requirements . 33Software Setup . 33.1 Download and cross compile PHP . 53.2 Cross compile example application. 63.3 configure Rootfs to contain SQLite pre-compiled binary . 63.4 configure Busybox httpd . 83.5 configure Cherokee webserver . 93.6 add files to your rootfs . 104Hardware Setup . 125Testing. 135.1 Testing with sqlite open() API (SQlite 2.8.17) . 135.2 Testing with PDO interface (SQlite 3.x support) . 141 Problem DescriptionDigi embedded modules running Digi Embedded Linux are delivered with pre-compiledout of the box web servers with PHP capabilities. Also a pre-compiled small embeddeddata base SQLite is provided. This document describes how to cross compile a third partyPHP interpreter and configure the web server(s) to execute it (e.g. with a test.php page). Italso describes how to configure the firmware for running SQLite data base and anexample to access it from PHP pages ran in the web server.Copyright 2010 Digi InternationalV1.3Page 2/15

PHP with Digi Embedded Linux2 RequirementsTo try the example in this document you need:Digi Connect ME 9210 or ConnectCore module mounted on Digi developmentboard.Digi Embedded Linux (DEL) 5.1 or above development environment.You can get everything together in a Digi Linux JumpStart Kit3 Software SetupFor your convenience find all files and images compiled into the archive this instructionscame with, you might want to skip this section.Install Digi Embedded Linux (DEL) 5.1 or higher, apply latest patches with thePackage Manager.Create a new Digi EL Kernel/Rootfs/U-Boot Project for yourplatform:Copyright 2010 Digi InternationalV1.3Page 3/15

PHP with Digi Embedded LinuxSelect Kernel and Root File System as projectcomponents:Copyright 2010 Digi InternationalV1.3Page 4/15

PHP with Digi Embedded LinuxSelect appropriate NFSROOT/TFTP Configuration3.1 Download and cross compile PHPDownload a recent stable PHP source code package from http://php.net/. This documenthas been tested with php-5.2.13.tar.bz2 and store/deflate it into your project directory:# cd HOME/ YOURWORKSPACE/ YOURPROJECTNAME# tar xjf php-5.2.13.tar.bz2# cd php-5.2.13Cross compile the PHP interpreter like this:Note: cross compilation will fail with php-5.3.2! Use php-5.2.13# export PATH /usr/local/DigiEL-5.2/usr/bin: PATHCopyright 2010 Digi InternationalV1.3Page 5/15

PHP with Digi Embedded Linux# CC arm-linux-gcc ./configure --host arm-linux --prefix /usr --without-iconv -disable-xml --without-pear --disable-libxml --disable-dom --disable-simplexml -disable-xmlreader --disable-xmlwriter --with-pdo-sqlite /usr/local/DigiEL5.2/usr# make# make INSTALL ROOT HOME/ YOURWORKSPACE/ YOURPROJECTNAME installIf you don’t see php-cgi in your project directory (the make install failed?), copy itmanually from built directory (or take the pre-compiled php-cgi from the zip attached).# find . –name php-cgi./sapi/cgi/php-cgi# cp sapi/cgi/php-cgi .3.2 Cross compile example application# export PATH /usr/local/DigiEL-5.2/usr/bin: PATH# cd HOME/ YOURWORKSPACE/ YOURPROJECTNAME# arm-linux-gcc sqlite test.c –o sqlite test –lsqlite33.3 configure Rootfs to contain SQLite pre-compiled binaryLaunch the project configuration:Copyright 2010 Digi InternationalV1.3Page 6/15

PHP with Digi Embedded LinuxEnable SQlite data base engine in the Rootfs Configuration/Pre-built applications:configure the kernel for POSIX file locking (CONFIG FILE LOCKING) which isneeded for SQLite:Save the changes.Copyright 2010 Digi InternationalV1.3Page 7/15

PHP with Digi Embedded Linux3.4 configure Busybox httpdIf you decide to use the pre-compiled httpd included in the busybox, you need to select itinto your project config (which is the default). Right click on your project and select“Configure project”. Select Rootfs Configuration, Pre-built applications and Busybox’shttpd web server(CONFIG DEL PACKAGE HTTPD)To enable the busybox httpd to launch the PHP interpreter when called with .php in theURL, add the following line to the /etc/httpd.conf of your rootfs:*.php:/usr/bin/php-cgiE.g. copy the default /usr/local/DigiEL-5.1/rootfs/rootfs extras/httpd/rootfs/etc/httpd.confinto your project directory and edit it.Copyright 2010 Digi InternationalV1.3Page 8/15

PHP with Digi Embedded Linux3.5 configure Cherokee webserverIf you decide to use the pre-compiled cherokee web server, you need to select it into yourproject config (disable busybox httpd for this first). Right click on your project and select“Configure project”. Select Rootfs Configuration, Pre-built applications deselectBusybox’s httpd web server and select Cherokee(CONFIG DEL PACKAGE CHEROKEE)To configure Cherokee to launch the PHP interpreter, add the following lines to ate 0vserver!10!rule!600!encoder!gzip 1vserver!10!rule!600!handler fcgivserver!10!rule!600!handler!balancer round robinvserver!10!rule!600!handler!balancer!source!1 1vserver!10!rule!600!handler!change user 0vserver!10!rule!600!handler!check file 1vserver!10!rule!600!handler!error handler 1vserver!10!rule!600!handler!pass req headers 1vserver!10!rule!600!handler!xsendfile 0vserver!10!rule!600!match extensionsvserver!10!rule!600!match!extensions phpvserver!10!rule!600!only secure 0source!1!host localhost:50000source!1!interpreter /usr/bin/php-cgi -b localhost:50000source!1!nick PHP Interpretersource!1!type interpreterCopyright 2010 Digi InternationalV1.3Page 9/15

PHP with Digi Embedded LinuxE.g. copy the default /usr/local/DigiEL5.1/rootfs/rootfs extras/cherokee/rootfs/etc/Cherokee/cherokee.conf into your projectdirectory and edit it.3.6 add files to your rootfsUnfold your project, select configs and open add files.sh. Add the php-cgi, the test.phpand the httpd.conf or cherokee.conf (according to your selected webserver) to the rootfs:Also add test.php, sqlite-example.php sqlite-pdo.php to your project directory.Copyright 2010 Digi InternationalV1.3Page 10/15

PHP with Digi Embedded LinuxBuilt the project:Copyright 2010 Digi InternationalV1.3Page 11/15

PHP with Digi Embedded LinuxInstall the project:4 Hardware SetupTurn off the development board.Connect the power cable.Plug the Connect ME 9210 or ConnectCore module to the development board.Connect Ethernet between development board and your development PC orswitch (for updating firmware).Connect a serial null modem cable (pins 2 and 3 crossed) to your host computer(e.g. COMA is the CONSOLE). Plug the cable into Serial Port A of the Digidevelopment board. On ConnectCore 9P9215 development board use Serial PortD (CONSOLE).Copyright 2010 Digi InternationalV1.3Page 12/15

PHP with Digi Embedded Linux5 TestingRun the new built kernel and rootfs on module (e.g. update the images in flash built insection 3 “update linux tftp;rootfs tftp;dboot linux flash”, or boot with NFS-root: “dbootlinux tftp”).5.1 Testing with sqlite open() API (SQlite 2.8.17)Start a web browser on your development host and point it to the IP of your module tocheck the php test page: http://192.168.42.30/test.phpIf you click on the SQLite example link (or enter URL: http://192.168.42.30/sqliteexample.php) you will see the output of the SQL statements executed in this PHP page.Copyright 2010 Digi InternationalV1.3Page 13/15

PHP with Digi Embedded LinuxIf you execute this a second time, you will get an error message, since the data base isalready existing:The generated test data base /tmp/test.db should by in SQlite 2.8.17 format.5.2 Testing with PDO interface (SQlite 3.x support)Point your browser to sqlite-pdo.php example, to create a SQLite 3 example data basewith PHP and PDO interface:Copyright 2010 Digi InternationalV1.3Page 14/15

PHP with Digi Embedded LinuxOn the serial console, run the sqlite test program to access the PHP created SQLite 3 database:/ # sqlite test /tmp/dogs pdo.sqlite 'select * from Dogs'Id 1Breed LabradorName TankAge 2Id 2Breed HuskyName GlacierAge 7Id 3Breed Golden-DoodleName EllieAge 4Id 4Breed LabradorName TankAge 2Id 5Breed HuskyName GlacierAge 7Id 6Breed Golden-DoodleName EllieAge 4Copyright 2010 Digi InternationalV1.3Page 15/15

PHP with SQLite on Digi Embedded Linux SQLite 2.8.17 supported with sql_.() API SQLite 3.x support via PDO

Related Documents:

Digi Connect ME Digi Connect EM ARM-Based Networking Modules Features Chart Processor Type Digi NS7520 Digi Connect Wi-ME Digi Connect Wi-EM Digi NS7520 Digi NS7520 Digi NS7520 ARM Core ARM7TDMI ARM7TDMI ARM7TDMI ARM7TDMI Processor Speed 55 MHz 55 MHz 55 MHz 55 MHz Memory Ba

2006 jun 19 new book about sqlite the definit guid to sqlite a new book by mike owen is now avail from apress the book cover the latest sqlite intern as well as the nativ c interfac and bind for php python perl rubi tcl and java recommend Remove Stop Words 2006 jun 19 new book about sqlite --- definit guid

SQLite version 3.7.15.2 2013-01-09 11:53:05 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite Finally, you have SQLite command prompt where you can issue SQLite commands for your exercises.

Exporting and importing a table as an SQL script Exporting a database is a simple two step process: sqlite .output mydatabase_dump.sql sqlite .dump Exporting a table is pretty similar: sqlite .output mytable_dump.sql sqlite .dump mytable The output file needs to be defined with .output prior to using .dump; otherwise, the text is just

PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side Where to Start? To get access to a web server with PHP support, you can: Install Apache (or IIS) on your own server, install PHP, and MySQL Or find a web hosting plan with PHP and

PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use What is a PHP File? PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP code are executed on the server, and the result is returned to the browser .

php architect's Guide to PHP Design Patterns A Practical Approach to Design Patterns for the PHP 4 and PHP 5 Developer Jason E. Sweat USA 21.99 Canada 29.99 U.K. 16.99 Net php architect's Guide to PHP Design Patterns Design patterns are comprehensive, well-tested solutions to common problems that developers everywhere encounter each day.

Archaeological illustration (DRAWING OFFICE) – DM‐W This week the class will be divided into two groups, one on the 25. th, the other on the 26. th, as the drawing office is too small for the entire group. Week 10 01.12.09 Introduction to the archaeology of standing remains (OUT) – DO’S Week 11 8.12.09 Interpreting environmental data (LAB) ‐ RT. 3 AR1009 28 September 2009 Reading The .