Document directory
- PHP version 4.4.8
- PHP and sqlite3
After several days of efforts, we finally built the Apache + SQLite + PHP platform on the arm-Linux platform.
Apche and SQLite have a lot of information on the Internet, but PHP for ARM-Linux is rare. it took a lot of time to install PHP on the ARM platform. so I will post the building process here, hoping to help you.
SQLite for ARM LinuxInstall
1. Download sqlite3.3.8: Go to http://www.sqlite.org/download.html, open the downloaded code package, and generate the sqlite3.3.8directory.
2. Modify the configure file and comment out the following statements.
# 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,Configuration
./Configure-Prefix =/data0/SQLite -- disable-TCL -- Host = arm-Linux
4. Modify the MAKEFILE file
Change BCC = arm-Linux-gcc-g-O2 to bcc = gcc-g-O2.
5. Modify the MAKEFILE file and compile the sqlite3 program as a static key library.
Libsqlite3.a compilation must be added first.
Then, set sqlite3 $ (texe): $ (top)/src/shell. C. libs/libsqlite3.la sqlite3.h
Change to lite3 $ (texe): $ (top)/src/shell. C. libs/libsqlite3.a sqlite3.h
Convert-o $ @ $ (top)/src/shell. C. libs/libsqlite3.la \
Change to-o $ @ $ (top)/src/shell. C. libs/libsqlite3.a \
6. Make
7. # arm-Linux-strip sqlite3
8. Upload sqlite3 to the terminal
9. sqlite3 program test
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. Test the C program
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
Upload the. Out Program to the terminal and execute
# A. out test "select * From TBL"
One = Hello
Two = 10
One = goodbye
Two = 20
Apache server for ARM Linux
1. Download apache_1.3.39.tar.gz from the http://www.apache.org/, decompress a directory, and then go to the apache_1.3.39 directory.
2. Use local GCC to compile this version and run:
./Configure
Make install is not required after make is complete.
3. Then, create a new compilation of armpits. Then, extract apache_1.3.39.tar.gz from the directory and go to apache_1.3.39 in the directory. Run:
Export cc = "arm-Linux-GCC"
./Configure -- prefix =/data0/Apache/-- without-execstrip -- enable-module = so
Then run the make command. The compilation will fail at apache_1.3.39/src/main/gen_test_char, because the program in the arm version cannot be run on the local machine, you need to overwrite the locally compiled apache_1.3.39/src/main/gen_test_char in this arm version, and then go to apache_1.3.39 in the arm version to continue making, then compile the program to another program apache_1.3.39/src/main/gen_uri_delims and overwrite it with the local version to continue making until the final compilation is successful.
4. -- prefix =/data0/Apache/specifies the installation directory as/data0/Apache/, run make install, all the compiled Apache programs of the arm version are installed in the/data0/Apache/directory. After compressing the directory, upload it to the terminal and modify CONF/httpd. conf configuration file.
5. make sure to modify CONF/httpd. conf, add servername www.willfar-ertu.com: 80, otherwise a warning httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.1.1 for servername will be reported when you start the service
6. run the following command to check whether Apache is successfully installed: http: // ip: 80. If the Apache instructions page is displayed, the installation is successful. if a 403 error message is displayed, check whether the Apache directory permission is 755, including the Apache parent directory.
PHP for ARM Linux
1. Download php-4.4.8.tar.gz from the http://www.php.net, extract a directory, and then go to the php-4.4.8 directory
2. Export cc = "arm-Linux-GCC"
3. Modify the configure file and comment out the cross-compilation error handling. For example:
# 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. Execute./configure. Some errors will be reported. Modify the configure file and comment out the error processing according to the error prompt until it is successful.
6. Modify the MAKEFILE file and set
Extra_libs =-lcrypt-L-lcrypt-LZ-lm-lcrypt
Replace
Extra_libs =-lcrypt-LZ-lresolv-lm-LDL-lnsl-lcrypt
If this parameter is not replaced, the system reports the "can not find-L-lcrypt" error at the end of the link.
7. Make
8. make install will report that the PHP program cannot be executed, back up the cross-compiled PHP to php_arm, and then replace the locally compiled PHP with the cross-compiled PHP. Continue to make install
9. after executing make install, the PHP Directory will be generated under the/data0 directory, copy the php-4.4.8/SAPI/CLI/php_arm to the/data0/PHP/bin directory, and then package the PHP Directory, upload it to the/data0 directory of the terminal and decompress it.
10. Upload the libphp4.so file under the php-4.4.8/. libs directory to the terminal/data0/Apache/libexec directory
11. Modify the following HTTD. conf file in the/data0/Apache/conf directory:
Add the following statement under # 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. Add the index. php file in the/data0/Apache/htdoc directory. The content of the file is as follows: <? Phpinfo ();?>
13. If http: // ip/index. php shows the PHP information, it indicates that PHP is successfully installed.
PHP version 4.4.8
System
Linux localhost 2.4.18-rmk7-pxa1 #2 4 December 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 and sqlite3
Download the php-sqlite3 package from the PHP website first
1. decompress the compressed package to a directory.
2. Go to the directory and run/data0/PHP/bin/phpize.
3 ../configure -- With-PHP-Config =/data0/PHP/bin/PHP-config -- with-sqlite3 = Your sqlite3 installation directory
4. Make
5. Make install
6. Put the generated sqlite3.so in the PHP extension directory.
7. Load the sqlite3.so module in PHP. ini.