Using PHP

AppWeb provides a PHP module for the high performance execution of PHP applications and scripts. You may use the supplied PHP library or you can replace it with a custom PHP build of your own choosing. Alternatively, you can even run PHP using the CGI interface if you have your own PHP program that you wish use.

PHP is enabled by default in the AppWeb configuration file and is loaded via the LoadModule configuration directive.

LoadModule php5 libphp4Module
AddHandler php5Handler .php

If you are using PHP version 4, replace the "5"s in the above example with "4"s. AppWeb supplies both a PHP4 and a PHP5 module. To use PHP, you need to create a web document with a ".php" extension. When your browser requests this page, AppWeb will automatically invoke PHP to process the page.

If you wish to use PHP via CGI, see the Using PHP via CGI section below.

When to Use PHP

PHP is a widely-used, general-purpose scripting language that is especially suited for enterprise Web development. It provides an object oriented programming language, numerous extensions and a broad developer community. The power of PHP comes at a price, it typically has a memory footprint of 1-2 MB for the PHP code alone and can be quite large (> 5MB) for  large applications. For embedded systems, this is often too big and so we recommend using Embedded Server Pages for such systems.

Release Details

AppWeb supplies two PHP modules. One based on PHP 5.0.0 and one based on PHP release 4.3.6. These modules are built with support for sessions, sockets, MySQL, XML, XML-RPC, regular expressions, large math, calendar functions, multi-byte strings, the pear library and the Berkeley database.

The AppWeb PHP module is called libphp5Handler.so on Linux and libphp5Handler.dll on Windows. These AppWeb modules load the PHP library which is called libphp4.so on Linux and libphp4.dll on Windows. You may replace the PHP library with a custom build from the PHP source base if you wish.

The supplied PHP library was configured with the following configuration options:

configure \
--cache-file=config.cache \
--disable-debug \
--disable-rpath \
--enable-bcmath \
--enable-calendar \
--enable-experimental-zts \
--enable-embed=shared \
--enable-force-cgi-redirect \
--enable-ftp \
--enable-inline-optimization \
--enable-magic-quotes \
--enable-memory-limit \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-mbregex \
--enable-pic \
--enable-safe-mode \
--enable-sockets \
--enable-track-vars \
--enable-trans-sid \
--enable-wddx \
--sysconfdir=/etc/appWeb \
--with-exec-dir=/etc/appWeb/exec \
--with-db4 \
--with-mysql \
--with-regex=system \
--with-pear \
--with-xml \
--with-xmlrpc \
--with-zlib

Using PHP via CGI

If you need to use PHP via CGI, be aware that PHP will run much more slowly. This will be especially aparent for small scripts where the load time for each script will be the dominant overhead.

To use PHP via CGI, you will need to disable the PHP module if you want your script to use the ".php" extension. If your scripts do not use this extension, you can keep the PHP module enabled. To enable PHP via CGI, add (or uncomment) the following lines in the appWeb configuration file :

AddHandler cgiHandler .cgi .cgi-nph .bat .cmd .pl .py
Action application/x-appWeb-php /usr/bin/php

To disable the PHP module, ensure that you have commented out the following lines:

# LoadModule php5 libphp5Module
# LoadModule php4 libphp4Module
# AddHandler php4Handler .php
# AddHandler php5Handler .php

When PHP is started as a CGI interpreter, it expects that the SCRIPT_FILENAME environment variable be set to the name of the script to execute. In early version of PHP, it incorrectly looked at PATH_TRANSLATED to have the name of the script. To ensure that PHP behaves correctly and looks in SCRIPT_FILENAME, ensure that the cgi.fix_pathinfo is set to 1 in the php.ini file.


© Mbedthis Software LLC, 2003-2204. All rights reserved. Mbedthis is a trademark of Mbedthis Software LLC.