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.


The sources for the native build are available at: JBossWeb php native sources

To build you need to check out the directory that contains the script:

  svn co jbosswebphp 

To build simply run

  cd jbosswebphp bash 

The will detect you platform, download and build the dynamic libraries the PHP library needs and build the PHP servlet itself. It creates a tarfile that contains the libraries and a war file with the examples.


The sources for the JAVA part are available at: JBossWeb php sources

Already build PHP servlets and libraries are available at: JBossWeb php 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:

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


Copy the 2 libraries and in $JBOSS_HOME/bin/native, something like:

  cp ./PHP/lib/ bin/native cp ./PHP/lib/ bin/native 

Installing on JBossAS 4.2.x and 5.0.x

Since version 1.0.2 the php module runs also in JBossAS 4.2.x and 5.0.x. The name of the packages has been named so you have to change the following to the above instructions: In $CATALINA_BASE/server.xml change:

      <Listener className="org.apache.catalina.servlets.php.LifecycleListener"/> 


      <Listener className="org.jboss.web.php.LifecycleListener"/> 

In $CATALINA_BASE/conf/web.xml change:








Replace the servlets-php.jar by jbossweb-extras.jar The lastest jbossweb-extras.jar is available at: jbossweb-extras.jar for php

Installing on JBossWeb 2.1.x

To install in JBossWeb 2.1.x you have to do something similar to the installation in 4.2.x and 5.0.x. Instead editing the $JBOSS_HOME/bin/run.conf edit $CATALINA_HOME/bin/ file.


(replace $CATALINA_BASE by its value) JBossWeb 2.1.x comes with servlets-php.jar in lib no need to copy the jbossweb-extras.jar. To run the demo you have to copy the server/default/deploy/jbossweb.sar/php-examples.war to webapps

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/64 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