Adding PHP support to SailFin

Category: Tech Comments: One comment

Finally it is now a breeze to enable PHP on SailFin. PHP is a server-side scripting language which has quite a large user base in the web development community. PHP code is embedded in HTML and sent to a webserver for interpretation. The webserver therefore needs to run a PHP interpreter. The guys from Caucho Technology have made a 100% Java implementation of such an interpreter, called Quercus. Quercus is delivered as a .war file and as such it can be ran on any Java application server – such as SailFin.

Quercus is not only an interpreter, it also offers PHP extensions allowing you to call server-side Java code directly from within your PHP script. The Caucho website offers some documentation on how to do that; this opens interesting possibilities on SailFin. You can now use JSR289 functionality directly from within PHP. For example, if you’re running a PHP guestbook, you could extend it to include SIP dial-out functionality.

To deploy Quercus, download the latest version, open the SailFin admin console, select Applications, then Web Applications, then Deploy… and point to the Quercus .war file you just downloaded. If all goes well, your admin console should look something like this:

phpsailfin1

To verify that your PHP engine is working, point your browser to the default PHP script that comes with the Quercus interpreter: http://localhost:8080/quercus-3.1.6/ (your HTTP port or Quercus version might of course be different). You should get the following screen:

phpsailfin21

Now go try out some PHP applications on your SailFin server; for example, you could run your own MediaWiki on your local SailFin server! To do so, download the latest MediaWiki distribution and unzip it in the Quercus interpreter root directory (assuming your running the default out-of-the-box domain called domain1):

[SailFin installdir]/domains/domain1/applications/j2ee-modules/quercus-3.1.6/

It’s probably a good idea to create a subdirectory for any PHP applications you try out, so for example:

[SailFin installdir]/domains/domain1/applications/j2ee-modules/quercus-3.1.6/wiki/

And that’s that, you now have a PHP wiki running on SailFin. Try it by pointing your browser to: http://localhost:8080/quercus-3.1.6/wiki/

Of course you will need to complete other steps, depending on the type of PHP application you’re developing or trying out. In the case of MediaWiki, you will need to setup a MySql server and create the appropriate JDBC objects in SailFin. I might describe how to do that in a later blog.

    One comment to Adding PHP support to SailFin

    • basketball jerseys  says:

      This is an interesting article. Thanks for sharing.

    Leave a reply

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>