Labels

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
http://anonsvn.jboss.org/repos/jbossreflex/trunk/php/jbossweb-extras.jar

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

<servlet>
<servlet-name>php</servlet-name>
<servlet-class>org.jboss.web.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.jboss.web.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>



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

http://download.jboss.com/jbossweb/modules/php/php5servlet-linux-i686-1.0.2.tar.gz

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.
LD_LIBRARY_PATH=/PHP/lib
export LD_LIBRARY_PATH

Restart your server now and make execute your php files.

NOTE:

No comments:

Post a Comment