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



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.


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


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:

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:
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:

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