Jetty Logo
Version: 9.2.2-SNAPSHOT
Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Configuring Jetty for FastCGI

Configuring Jetty to Proxy HTTP to FastCGI
Configuring Jetty to Proxy SPDY to FastCGI

In this section you will see how to configure Jetty to serve WordPress via FastCGI.

The first step is to have WordPress installed in your server machine, for example under /var/www/wordpress. For more information about how to install WordPress, please refer to the WordPress Installation Guide.

The second step is to install php-fpm and make sure it is configured to listen on a TCP socket; typically it is configured to listen to localhost:9000.

The third step is to install Jetty, for example under /opt/jetty. Refer to Downloading Jetty for more information about how to install Jetty.

The fourth step is to create a Jetty base directory (see Managing Jetty Base and Jetty Home), called in the following $JETTY_BASE, where you setup the configuration needed to support FastCGI in Jetty:

$ mkdir -p /usr/jetty/wordpress
$ cd /usr/jetty/wordpress
    

Therefore $JETTY_BASE=/usr/jetty/wordpress.

The fifth step is to deploy the web application that provides the proxying of client requests to the FastCGI server, php-fpm. Typically this is done by deploying a *.war file in the $JETTY_BASE/webapps directory, but in case of FastCGI there is really nothing of this web application that you have to write: all the work is already done for you by the Jetty developers. Therefore you just need to deploy a Jetty XML file that configures the web application directly. Copy and paste the following content as $JETTY_BASE/webapps/jetty-wordpress.xml

Explanation of this file content:

Configuring Jetty to Proxy HTTP to FastCGI

In order to configure Jetty to listen for HTTP requests from clients and forward them to the FastCGI server as FastCGI requests, you need to specify a start.ini file that configures the Jetty modules that are needed for Jetty to proxy HTTP to FastCGI. The minimal start.ini file is the following:

At this point, you can start Jetty (see Chapter 9, Starting Jetty), hit http://localhost:8080 with your browser and enjoy WordPress:

$ cd $JETTY_BASE
$ java -jar /opt/jetty/start.jar
        

Configuring Jetty to Proxy SPDY to FastCGI

In order to configure Jetty to listen for SPDY requests from clients that are SPDY enabled and forward them to the FastCGI server as FastCGI requests, you need to specify a start.ini file that configures the Jetty modules that are needed for Jetty to proxy SPDY to FastCGI.

Remember that for SPDY to work you will need to run over SSL, and you will need the NPN boot jar in the boot classpath, as explained in Configuring SPDY.

Since now your site will run over SSL, you need to make sure that the WordPress URL is also configured so. If you have followed the steps of the Configuring Jetty to Proxy HTTP to FastCGI, your WordPress site is served at http://localhost:8080. You will need to change that to be https://localhost:8443 from the WordPress administration web interface, or follow the WordPress instructions to do so without using the administration web interface.

The minimal start.ini file is the following:

Note that we specified the spdy.port to be 8443.

At this point, you will need the NPN boot jar and the SSL certificate. In this example, you can obtain them very easily using the built-in feature of the Jetty start mechanism that downloads required dependencies, see Chapter 9, Starting Jetty. However, remember that the example SSL certificate that is downloaded will not be valid for your website and that it must not be used in production. It is provided only for testing and example purposes. To leverage the automatic download of required dependencies, issue this command:

$ cd $JETTY_BASE
$ java -jar /opt/jetty/start.jar --create-files
        

At this point, you can start Jetty (see Chapter 9, Starting Jetty), hit http://localhost:8080 with your browser and enjoy WordPress via SPDY using a SPDY enabled browser:

$ cd $JETTY_BASE
$ java -Xbootclasspath/p:lib/npn/npn-boot-<version>.jar -jar /opt/jetty/start.jar
        

If you don't have a SPDY enabled browser, WordPress will still be available over plain HTTPS.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2014-08-21T01:00:25-07:00)