Wednesday, June 13, 2012

How to implement PHP Scripts in JBOSS?

In case if you are using any PHP application in JBOSS AS [Application Server] no need for installing specially PHP Engine into your machine, you just configure jboss.web services in JBOSS AS in enough. Lets see how to Configure PHP in JBOSS AS.

Download the jbossweb-extras.jar using following URL

This jar file contains the Listeners for the PHP, move this jar file to $JBOSS_HOME/server/<your_server>/deploy/jboss-web.deployer directory.
[ JBOSS_HOME in the sense that Location of your Jboss ex: /usr/jboss-4.2.0.GA in Linux].

In the same Location get the server.xml file and edit it, add the following Listener code to that file <Listener classname="org.jboss.web.php.LifecycleListener"/>

Then move to $JBOSS_HOME/server//deploy/conf directory and edit the web.xml file and add the following codes in order to make URL pattern mapping



Then download the .so [Shared Object] files for PHP in order make PHP as servlet from the following URL,

Uncompress it,

]# tar -zxf php5servlet-linux-i686-1.0.2.tar.gz

So you will get php5servlet-linux-i686-1.0.2 directory contains a single directory named PHP. we are going to map this directory to JBOSS AS so for naming convention make “php5servlet-linux-i686-1.0.2/PHP” as “PHP” by using

]# mv php5servlet-linux-i686-1.0.2/PHP PHP

Now you have the location of this PHP directory which contains *.so files. Goto $JBOSS_HOME/bin directory and edit run.conf file and add the following lines to set the library path for the downloaded *.so files.

Restart your server now and make execute your php files.


No comments:

Post a Comment