Embedded Web Service Program Appweb

Source: Internet
Author: User
Tags builtin crypt pear ranges vars zts zend

We use the open source embedded Web Services program Appweb to provide webserver services for Landog and Oabox projects. Here is a link to the Appweb project:

http://www.appwebserver.org/: Official website

http://www.appwebserver.org/forum/index.php: Help Forum

We use the latest appweb-2.2.2 version as follows:

Http://www.appwebserver.org/software/appweb-src-2.2.2-5.tar.gz

The Oabox project requires PHP5 and SSL support, compiling PHP5 and Matrixssl before compiling the appweb.

For Appweb configuration See the following page:

/appwebconfig: Configuring Appweb

PHP5

Since PHP5 requires support for zlib libraries and LIBXML2 libraries, we first cross-compile the zlib library.

Zlib

To download zlib-1.2.3.tar.gz to the ~/webserver/src/directory, run the following command:

$ CD ~/webserver/
$ tar xvzf src/zlib-1.2.3.tar.gz
$ CD ZLIB-1.2.3/
$ CC=ARMEB-LINUX-GCC./configure--shared
$ make
$ cp-d libz.so*/your/crosscompile/path/lib/ //Copy the generated dynamic library to the cross compiler's Lib directory
$ CP zlib.h/your/crosscompile/path/include/ //Copy the zlib header file to the cross compiler's include directory
$ CP zconf.h/your/crosscompile/path/include/

Libxml2

To download libxml2-2.6.28.tar.gz to the ~/webserver/src/directory, run the following command:

$ CD ~/webserver/
$ tar xvzf src/libxml2-2.6.28.tar.gz
$ CD libxml2-2.6.28/
$./configure--host=armeb-linux
$ make

After compiling, generate LIBXML2 dynamic libraries under the. libs/directory, and copy them to the cross compiler's lib directory:

$ cp-d. libs/libxml2.so*/your/crosscompile/path/lib/

PhP5

To download the PHP-5.2.3.TAR.BZ2 package to the ~/webserver/src/directory, run the following command:

$ CD ~/webserver/
$ tar jxvf src/php-5.2.3.tar.bz2
$ CD PHP-5.2.3/
$ Export CC=ARMEB-LINUX-GCC
$ Export Ar=armeb-linux-ar
$ Export cxx=armeb-linux-c++
$ Export Ranlib=armeb-linux-ranlib
$ Export Strip=armeb-linux-strip
$ Export LD=ARMEB-LINUX-LD
$ Export NM=ARMEB-LINUX-NM

Since PHP has a direct cross-compilation problem, we also want to modify the Configure file:

$ VI Configure
Add 106003 rows:
{echo "Configure:error:Your system seems to lack POSIX threads." 1>&2; Exit 1; }
To be replaced by:
{echo "Configure:error:Your system seems to lack POSIX threads." 1>&2; } #exit 1; }

After you save the exit, execute the following command:

$./configure--prefix=/home/lvl/install/php5.0/--host=armeb-linux--target=armeb-linux--cache-file=config.cache- -disable-debug--disable-rpath--enable-bcmath--enable-calendar--enable-embed=shared--enable-maintainer-zts-- Enable-force-cgi-redirect--enable-ftp--enable-inline-optimization--enable-magic-quotes--enable-memory-limit-- Enable-pic--enable-safe-mode--enable-sockets--enable-track-vars--sysconfdir=/home/lvl/install/php5.0/etc/ Appweb--enable-mbstring=cn--enable-sqlite--without-pear--without-iconv--with-zlib--disable-ipv6

Due to the cross compiler flaw, partial detection is not performed correctly when configure needs to modify some content:

Modify Main/php_config.h

$ VI main/php_config.h
In line 1810: (may also be elsewhere)
/* #undef Have_stdarg_prototypes */
Add the following:
#define HAVE_STDARG_PROTOTYPES 1

Modify Makefile

$ VI Makefile
Add 65 Rows:
Extra_libs =-lcrypt-lcrypt-lrt-lz-lm-lxml2-lxml2-lxml2-lcrypt-lxml2-lxml2-lxml2-lcrypt
Switch
Extra_libs =-LCRYPT-LCRYPT-LRT-LZ-LM-LXML2-LXML2-LXML2-LCRYPT-LXML2-LXML2-LXML2-LCRYPT-LPTHREAD-LDL

After you have modified it, you can compile it:

$ make
$ makeinstall

The PHP program is installed in the/home/lvl/install/php5.0/directory, where Libphp5.so is below the Lib directory.

Matrixssl

Appweb supports HTTPS access, we need an SSL library for this function. Appweb supports OpenSSL and Matrixssl because Matrixssl is small and easy to cross-compile, so we use MATRIXSSL. First download the matrixssl-1-8-3-open.tar.gz to the ~/webserver/src/directory and run the following command:

$ CD ~/webserver/
$ tar xvzf src/matrixssl-1-8-3-open.tar.gz
$ CD matrixssl-1-8-3-open/src/

Modify Makefile:

$ VI Makefile
Will:
CC = gcc
STRIP = STRIP
Ar = ar
Ranlib = Ranlib
Switch
CC = ARMEB-LINUX-GCC
STRIP = Armeb-linux-strip
AR = Armeb-linux-ar
Ranlib = Armeb-linux-ranlib

Save to run after exiting:

$ make

Appweb

To download appweb-src-2.2.2-5.tar.gz to the ~/webserver/src/directory, run the following command:

  • --enable-ranges--with-cgi=loadable--with-php5=builtin \--with-php5-libs= "php5 crypt resolv z" \--with-php5-dir= "/ Home/lvl/landog/web/php-5.2.3/"\--with-php5-libpath=/home/lvl/landog/web/php-5. ...

  • --enable-ranges--with-cgi=loadable--with-php5=builtin \
    --with-php5-libs= "php5 crypt resolv z" \
    --with-php5-dir= "/home/lvl/landog/web/php-5.2.3/" \
    --with-php5-libpath=/home/lvl/landog/web/php-5.2.3/libs/\
    --with-php5-iflags= "-i/home/lvl/landog/web/php-5.2.3 \
    -i/home/lvl/landog/web/php-5.2.3/main \
    -i/home/lvl/landog/web/php-5.2.3/zend \
    -I/HOME/LVL/LANDOG/WEB/PHP-5.2.3/TSRM "

    Some files need to be modified in order to compile correctly:

    $ VI Appweb/makefile
    Modify Line 77:
    LIBPATH + = $ (bld_top)/$ (Bld_php5_dir)
    For:
    LIBPATH + = $ (bld_php5_dir)/libs/

    Save to run after exiting:

    $ make
    $ makeinstall
    Eaccelerator compiling eaccelerator

    Eaccelerator is a program used to speed up the operation of PHP, and is typically loaded in the form of dynamic modules. But in the cross-compiled module does not load properly, we need to compile eaccelerator into the libphp.so inside.

    First download eaccelerator-0.9.5.1.tar.bz2 to ~/webserver/src/directory, run the following command to extract Eaccelerator to the Php-src/ext directory:

    $ CD ~/webserver/
    $ tar jxvf src/eaccelerator-0.9.5.1.tar.bz2
    $ MV Eaccelerator-0.9.5.1/eaccelerator
    $ MV eaccelerator/php-5.2.3/ext/

    The extracted Eaccelerator directory does not have configure files, we need to install the above/home/lvl/install/php5.0/bin/inside the phpize to generate configure files:

    $ CD php-5.2.3/ext/eaccelerator/
    $/home/lvl/install/php5.0/bin/phpize //Build your own installed Phpize file

    We need to regenerate the PHP5 configure file with the Eaccelerator option:

    $ CD ~/WEBSERVER/PHP-5.2.3/
    $ RM Configure
    $./buildconf--force //system must have more than autoconf-2.13 version

    Add--enable-eaccelerator and--with-eaccelerator-shared-memory to rerun the Configure in the configuration options:

     $ export Bld_ar_for_host=armeb-linux-ar 
    $ export BLD_CC_FOR_HOST=ARMEB-LINUX-GCC
    $ export Bld_ld_for_host =ARMEB-LINUX-LD
    $ export bld_strip_for_host=armeb-linux-strip
    $ export bld_ar_for_build=ar
    $ export BLD_CC_ FOR_BUILD=/USR/BIN/CC
    $ export bld_ld_for_build=/usr/bin/ld
    $ export Bld_strip_for_build=/usr/bin/strip
    $ ./configure--prefix=/home/lvl/install/php5.0/--host=armeb-linux--target=armeb-linux--cache-file=config.cache-- Disable-debug--disable-rpath--enable-bcmath--enable-calendar--enable-embed=shared--enable-maintainer-zts-- Enable-force-cgi-redirect--enable-ftp--enable-inline-optimization--enable-magic-quotes--enable-memory-limit-- Enable-pic--enable-safe-mode--enable-sockets--enable-track-vars--sysconfdir=/home/lvl/install/php5.0/etc/ Appweb--enable-mbstring=cn--enable-sqlite--without-pear--without-iconv--with-zlib--disable-ipv6-- Enable-eaccelerator--with-eaccelerator-shared-memory

    Before configuring, you need to modify the Configure file as described above, and then modify the makefile and Main/php_config.h files after running configure. Also, modify the Ext/eaccelerator/mm.c file:

    $ VI EXT/EACCELERATOR/MM.C
    Insert in line 30th:
    #define MM_SEM_IPC 1
    #define MM_SHM_IPC 1

    Save to run after exiting:

    $ make

    After running, generate the libphp5.so file under the Libs directory. Due to our Appweb configuration:--with-php5=builtin (with--with-php5=loadable when the module is not found!) So after compiling the libphp5.so, you need to recompile the appweb again.

    Configure Eaccelerator

    After recompiling Appweb and make install, Appweb installs in the "--prefix" directory specified when compiling appweb (for example,/mnt/appweb/). We need to modify the php.ini in this directory to make Eaccelerator effective:

    $ cd/mnt/appweb
    $ sudovi php.ini (requires root user rights)
    At the end of the file, add the following:
    Eaccelerator.shm_size= "16"
    Eaccelerator.cache_dir= "/tmp/eaccelerator"
    eaccelerator.enable= "1"
    Eaccelerator.optimizer= "1"
    Eaccelerator.check_mtime= "0"
    eaccelerator.debug= "0"
    Eaccelerator.filter= ""
    eaccelerator.shm_max= "0"
    Eaccelerator.shm_ttl= "300"
    Eaccelerator.shm_prune_period= "300"
    eaccelerator.shm_only= "0"
    eaccelerator.compress= "1"
    Eaccelerator.compress_level= "9"

    Copy the/mnt/appweb/directory on the host to the/mnt/directory on the board (the Armeb-linux-strip tool is used to remove the Appweb program and the debug information and symbolic information in the lib/modules/directory dynamic library before copying).

    Create a eaccelerator directory

    In the startup script of the Development Board, add:

    Mkdir/tmp/eaccelerator
    chmod 0777/tmp/eaccelerator

    This directory is used as the directory where cached data is saved.

    Confirm Eaccelerator Run

    Under normal circumstances, the way to verify that Eaccelerator is working is to open a PHP page with the following code in a browser:

    If Eaccelerator is running properly, the Phpinfo page will show:

    Zend Engine v2.1.0 Copyright (c) 1998-2006 Zend Technologies
    With Eaccelerator v0.9.5-beta2 Copyright (c) 2004-2006 Eaccelerator by Eaccelerator

Embedded Web Service Program Appweb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.