![]() |
![]() |
||||
Thanks to the wonderful people at Resin, most PHP applications and websites can be used with Tomcat by installing Quercus.
Traditional PHP hosting introduces a number of security issues due to the way Apache runs all sites under the same www-data account. There are a number of work-arounds, but it's a continual balancing act between performance, flexibility and security.
PHP binaries are written in C, so new buffer overflows and similar issues are reported and fixed monthly by the PHP developers.
By using Quercus to run PHP at Metawerx, security is handled by your already secured metawerx java hosting account. PHP binaries are not used, because everything is recompiled into Java on the fly and run by the Java VM, as 100% java instead.
With Quercus, PHP is compiled into java classes when you change it (like JSP) and then gets all the performance benefits from Java and the HotSpot compiler.
For a normal PHP request, the PHP script is loaded, parsed and executed in separate processes. These are much slower than a Java VM running java classes in separate threads. PHP professionals increase the performance of their systems using caching methods and utilities to keep a PHP instance in memory rather than loading a new instance for each request. With Java, we don't have to worry about that however, because the PHP is compiled into java classes and run by the Java VM.
According to a performance report by Aaron Stewart using Drupal (a popular PHP application), Quercus ran on Resin at around 3.5-4x faster than a standard PHP install.
There is also a great article on JavaLobby about Quercus that is worth a read if you are planning on moving from a PHP-based host to Tomcat or Resin as your PHP engine of choice.
Java and PHP can sit side-by-side on the same website, and you can use the same database between them as well.
This allows you to do snazzy things such as integrating your existing userbase with the WordPress, Drupal, MediaWiki or phpBB user databases to instantly enhance your user's capabilities when they're at your site. For example, if you already maintain a list of users, with a little work, they could use the same login and password to comment on the posts on your company blog or forum.
PHP and Java objects can even talk to each other, allowing the creation of SSO (Single Sign On) from your Java-based website or application, across to a PHP based forum or wiki.
You can install Quercus into your application directly by checking the entries in it's web.xml file, and importing the libraries in it's lib folder, or as a separate application.
This guide will show how to install it as a separate application.
You should now be able to access http://yoursite/php and see the Quercus test index.php file
Most PHP software works fine with Quercus, so upload some PHP and try it out, or continue below to install some popular PHP software.