JBoss, a division of Red HatJBoss.org - Community driven.
Printer Friendly Version

Overview

Introduction

The PHP Module is a servlet that allows to run PHP embedded scripts. The servlet calls a native embedded PHP engine with libraries extentions. The PHP servlet allows to run most of the existing PHP scripts.

Building

To build simply run buildphp.sh. The buildphp.sh will detect you platform, download and build the dynamic libraries the PHP library needs and build the PHP servlet itself. Should should get a tarfile that contains the libraries and a war file with the examples.

Already build PHP servlets and libraries are available at: JBossWeb download area

Installing

After extracting the tarball corresponding to you platform. (For example in $JBOSS_HOME, where JBOSS_HOME should be something like jbossweb-1.0.0.GA).
In $CATALINA_BASE (CATALINA_BASE should be something like jbossweb-1.0.0.GA/server/default/deploy/jbossweb.sar) do the following:
Edit in the <Server/> of $CATALINA_BASE/server.xml and uncomment the following Listener entry:
    <Listener className="org.apache.catalina.servlets.php.LifecycleListener"/>
If you want to enable php in all contexts edit $CATALINA_BASE/conf/web.xml and uncomment the php servlet description and its mapping:
   <servlet>
        <servlet-name>php</servlet-name>
        <servlet-class>org.apache.catalina.servlets.php.Handler</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
         <load-on-startup>6</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>phps</servlet-name>
        <servlet-class>org.apache.catalina.servlets.php.Highlight</servlet-class>
    </servlet>


    <servlet-mapping>
        <servlet-name>php</servlet-name>
        <url-pattern>*.php</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>phps</servlet-name>
        <url-pattern>*.phps</url-pattern>
    </servlet-mapping>
Edit the $JBOSS_HOME/bin/run.conf (JBOSS_HOME should be something like jbossweb-1.0.0.GA) add the LD_LIBRARY_PATH variable and modify/add (replace $JBOSS_HOME by its value) the java.library.path parameter of the JVM:
LD_LIBRARY_PATH=$JBOSS_HOME/PHP/lib
export LD_LIBRARY_PATH
Copy the 2 libraries libphp5.so and libphp5servlet.so in $JBOSS_HOME/bin/native, something like:
cp ./PHP/lib/libphp5.so bin/native
cp ./PHP/lib/libphp5servlet.so bin/native

Using the php demo scripts

The php-examples.war warfile of the tarball contains some php demo scripts. The warfile should be located in $CATALINA_BASE. They are deployed under /php-examples to use them you only need to modify the $JBOSS_HOME/bin/run.conf as described above.
You don't have to modify the $CATALINA_BASE/conf/web.xml nor the $CATALINA_BASE/server.xml files. You have to start and restart the servlet container because of the environment modifications.
To use the examples, try http://localhost:8080/php-examples/index.php.

Additing extension libraries

For the moment this feature is only supported on Solaris. Edit the php.ini file and add your library extensions as in the following example:
extension_dir=/home/jfclere/SunOS_i386_tools/PHP/lib/php/extensions/no-debug-zts-20050922
extension=openssl.so
extension=pdo_pgsql.so
extension=pgsql.so

Installing on win32 machines

Copy the demo webapps/php-examples.war to ./server/default/deploy.
Edit server/default/deploy/jbossweb.sar/server.xml as in other OS.
Copy the dlls in bin/native