Running PHP With Quercus in Sun Java System Web Server

   
By Sriram Natarajan and Marina Sum, October 9, 2007  

Sun Java System Web Server runs on all major operating systems and supports numerous dynamic content technologies, such as Java Servlet, JavaServer Pages, JavaServer Faces, Active Server Pages, PHP, ColdFusion, Netscape API, CGI, and Ruby on Rails, for developing Web applications. Its latest release, Sun Java System Web Server 7.0 Update 1 (henceforth, Web Server), is available for free download.

You can take advantage of the Java EE 5 platform-compliant Web container in Web Server to build reliable and scalable Web applications that are in demand from large enterprises nowadays. With Caucho Technology's Quercus, an open-source, Java technology implementation of PHP 5, you can also leverage that Web container for developing highly scalable PHP applications.

This article describes how to configure Quercus as a Web application within the Web container in Web Server to run PHP-based applications, such as Drupal and MediaWiki.

Note: Type each of the command lines in this article on one line even though, because of screen-width constraints, some of them wrap to the next line.

Contents
 
Downloading the Software
Creating a Sample Configuration
Deploying the Web Application
Acknowledgment
References
 
Downloading the Software

First, download and install the software required:

  1. Download Web Server 7.0 Update 1.

    See the collection of documentation and a helpful blog by Sun engineer Ajay Acharya: Sun Java System Web Server 7.0 Installation Demo .
  2. Download the Quercus PHP WAR file, currently in Beta.
Creating a Sample Configuration

To try out the approach, create a configuration and instance named quercus and deploy it on Web Server. For a demo of the procedure involved in the Web Server Administration Console, see Ajay Acharya's screencast.

Tip: To avoid having the Administration Server ( wadm) prompt you for a password with every command, follow this procedure to save the password and other related information.

To create the configuration and instance on the command-line interface (CLI), do the following:

Note: The file conventions in the following commands are those for the Windows platform.

  1. Go to the Web Server installation directory, for example:
    cd C:\Program Files\Sun\WebServer7
  2. Start the Administration Server. Type:
    C:\Program Files\Sun\WebServer7> admin-server\bin\startserv.bat
  3. Create a configuration and instance. Below are the command lines and output.

    C:\Program Files\Sun\WebServer7> bin\wadm.bat create-config --user=admin
    --password-file=.password --http-port=8084 --server-name=sriramn quercus
    
    CLI201 Command 'create-config' ran successfully
    
    C:\Program Files\Sun\WebServer7> bin\wadm.bat create-instance --user=admin
    --password-file=.password --config=quercus sriramn
    
    CLI201 Command 'create-instance' ran successfully
    
     
    Web Server creates a directory called https-quercus in your Web Server installation directory.
Deploying the Web Application

Now deploy the Quercus PHP Web application (the WAR file) to Web Server either in the Administration Console or with the CLI. To use the CLI, type these two commands:

C:\Program Files\Sun\WebServer7> bin\wadm.bat add-webapp --user=admin --config=quercus --vs=quercus --uri=/php /quercus-3.1.2.war WAR-file-dir

C:\Program Files\Sun\WebServer7> bin\wadm.bat deploy-config --user=admin quercus

Finally, stop and restart the Web Server quercus server instance and you'll be able to access the PHP home page ( index.php) within the Web application: Just go to http://localhost:8084/php/index.php. This welcome page is displayed:

 

You can now configure and run PHP scripts within Web Server. Be sure to create the scripts within your Web application's context root. In our example, the context root is C:\Program Files\Sun\WebServer7\https-quercus\web-app\quercus\php.

Acknowledgment

Special thanks to Caucho Technology's Quercus team for making the Quercus PHP WAR file available for download.

References
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
JavaOne Banner Java 8 banner (182)