Install & Configure Apache, PHP, JSP, Ruby on Rails, MySQL, PHPMyAdmin & WordPress on Windows XP/2000

Install JSP

Prerequisites

Java 2 Standard Edition

Visit http://java.sun.com/javase/downloads/ and click the Download link next to Java Runtime Environment (JRE) 5.0 Update 8. Accept the license agreement and then download Windows Offline Installation, Multi-language (15.74MB).

Version: J2SE Runtime Environment 5.0 Update 8
File Name: jre-1_5_0_08-windows-i586-p.exe
Download Location: http://java.sun.com/javase/downloads/

Jakarta Tomcat

On the Jakarta Tomcat 5 Download page, click on the Windows Executable link for "Core" version 5.5.20 to begin downloading.

Version: 5.5.20
File Name: apache-tomcat-5.5.20.exe
Download Location: http://tomcat.apache.org/download-55.cgi

Apache-Tomcat Connector

Download mod_jk.so from http://tomcat.apache.org. Click on Tomcat Connectors (under "Download" on the left-hand side), and then click JK 1.2 Binary Releases. Under Win32, select jk-1.2.19 and find mod_jk-apache-2.2.3.so.
Note: Don’t use mod_jk2. It has been deprecated.

Version: 1.2.19
File Name: mod_jk-apache-2.2.3.so
Download Location: /tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.19/

Install J2SE Runtime Environment 5.0 Update 6

  1. Run jre-1_5_0_08-windows-i586-p.exe. Select "Typical setup - All recommended features will be installed" and then click Accept >.
    Accept the license agreement, and then click Next >
  2. Click Finish.
    Click Finish

Install Jakarta Tomcat

  1. Run apache-tomcat-5.5.20.exe. Click Next >.
    Click Next >
  2. Click I Agree.
    Click I Agree
  3. Select "Full" from the dropdown, and then click Next >.
    Select "Full", and then click Next >
  4. Click Next >.
    Click Next >
  5. Enter an admin password, and then click Next >.
    Enter a password, and then click Next >
  6. Verify the J2SE 5.0 JRE installation path is correct, and then click Install.
    Click Install
  7. Uncheck "Show Readme", and then click Finish.
    Click Finish
    Tomcat Starting

Test Tomcat

  1. You should see a new system tray icon for Tomcat.
    Tomcat System Tray Icon
  2. Open http://localhost:8080/ in a web browser. If you see something like the following, you have successfully installed Tomcat!
     Tomcat Test

Install mod_jk.so

  1. Move mod_jk-apache-2.2.3.so to C:\Program Files\Apache Software Foundation\Apache2.2\modules.
  2. Rename it to mod_jk.so.
  3. Add the following to the end your Apache httpd.conf file.
    Include "C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\auto\mod_jk.conf"
  4. Add the following line to the server.xml file before "<Host name="localhost" appBase="webapps"
    " in C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf. (around line 192)
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>

    <Listener className="org.apache.jk.config.ApacheConfig" modJk="C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so" />
  5. Create a new text file called workers2.properties and paste the following into it. Save this file in the following directory:
    C:\Program Files\Apache Software Foundation\Apache2.2\conf
    [logger]
    level=DEBUG
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.log
    [config]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/conf/workers.properties
    debug=0
    debugEnv=0


    [shm]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.shm
    size=1048576

    # socket channel
    [channel.socket:localhost:8009]
    port=8009
    host=127.0.0.1

    # worker for the connector
    [ajp13:localhost:8009]
    channel=channel.socket:localhost:8009

    [status:status]

    [uri:/status/*]
    worker=status:status

    [uri:/jsp-examples/*]
    worker=ajp13:localhost:8009

    [uri:/*.jsp]
    worker=ajp13:localhost:8009
  6. Restart Tomcat by right-clicking on the Apache Tomcat taskbar icon. Select stop service, and then start service. It should create new directories in C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf called "auto" and "jk" with a file "mod_jk.conf" in the auto directory.
  7. Restart Apache. (Left click on the Apache taskbar icon and select Apache2 > Restart.

Test JK2 Connector

  1. Stop both Apache and Tomcat.
  2. Start Tomcat, and then start Apache.

    Note: Always start Tomcat first, and then start Apache. If you have to bounce Tomcat, remember to take down Apache first and restart it after Tomcat is up and running.

  3. Open http://localhost:8080/ in a web browser. If you see something like the following, Tomcat restarted successfully.
     Tomcat Test
  4. Open http://localhost/ in a web browser. If you see something like the following, Apache restarted successfully.
    Apache Test
  5. Open http://localhost/phpinfo.php in a web browser. If you see something like the following, PHP loaded successfully.

    Note: If you did not install PHP, skip this step.
    phpinfo page
  6. Open http://localhost/jsp-examples/ in a web browser. If you see something like the following, you have successfully installed the JK connector!
    JK2 Connector Test

Configuration

If anyone knows a better way of doing this, please drop me a line.

To Configure Tomcat to use your Apache DocumentRoot instead of it's own:

  1. Open server.xml from C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\. Find the <host> tag and edit the following:
    <Host name="localhost" appBase="C:/Program Files/Apache Software Foundation/Apache2.2"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
  2. Right after the <host> tag, add the following context:
    <Context path="" docBase="htdocs" reloadable="true" />
  3. For each webapp you want to run, you must add it to the workers2.properties file. For example, if you have a webapp in a folder APACHE_ROOT/htdocs/mywebapp, you need to add the following to the workers2.properties file in C:\Program Files\Apache Group\Apache2\conf.
    [uri:/mywebapp/*.jsp]
    worker=ajp13:localhost:8009

Alternatively, to configure all requests to go to the Tomcat Webroot directory.

Note: Doing this would break PHP functionality.

  1. Update your workers2.properties file to look like the following:
    [logger]
    level=DEBUG
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.log
    [config]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/conf/workers.properties
    debug=0
    debugEnv=0


    [shm]
    file=C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk2.shm
    size=1048576

    # socket channel
    [channel.socket:localhost:8009]
    port=8009
    host=127.0.0.1

    # worker for the connector
    [ajp13:localhost:8009]
    channel=channel.socket:localhost:8009

    [status:status]

    [uri:/status/*]
    worker=status:status

    [uri:/*.jsp]
    worker=ajp13:localhost:8009

    [uri:/*/*]
    worker=ajp13:localhost:8009
  2. Remove the Include "C:/Progra... .../Tomcat 5.5/conf/auto/mod_jk.conf" line from httpd.conf. Add the following:
    <IfModule !mod_jk.c>
       LoadModule jk_module "C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so"
    </IfModule>

    <VirtualHost localhost>
       ServerName localhost

       JkMount /* ajp13
       JkMount /*/* ajp13
       JkMount /*.jsp ajp13

    </VirtualHost>