Installing Apache 2.0.59 to a Windows-based computer, locally: Part 3

In Part 1 of this Apache 2.0.59 guide, we setup Apache 2.0.59 on a Windows XP SP2 machine. We also setup Perl and mod_perl, attempting to mimic our Apache 1.3.34 install. In Part 2 of this Apache 2.0.59 guide, we setup ColdFusion MX 6.1 and 7.0. This time, we'll be continuing in our quest by adding support for both PHP 4 and PHP 5.

In previous guides, we installed PHP 4 and PHP 5, so if you need to install either one, do so with the above directions. If you'll be installing PHP 4 and PHP 5 for the first time, and have not installed on Apache 1.3.x already, then you may be able to pick and choose from these guides to get the information you need.

Before we do this, however, we need to think about just what we're doing.

Up until this point, you may have installed any (or none) of the below. (Keep in mind that you can generalize these if you have slightly newer versions. So, PHP 5.1.4 = PHP 5.x.)

  • Apache 1.3.34
  • Apache 2.0.59
  • PHP 4.4.2
  • PHP 5.1.4
  • ColdFusion MX 6.1
  • ColdFusion MX 7.0.2

This gives us a number of options on what our local Web server could be running at one time. For example, we could be running PHP 4, ColdFusion MX 6.1, and Apache 1.3.x or Apache 2.0.x. Likewise, we could use PHP 4 or PHP 5, or ColdFusion MX 6.1 or ColdFusion MX 7.0. Writing out a list of all of our possible combinations, we've got something like the following.

  1. Apache1.3_CF6.1_PHP4
  2. Apache1.3_CF7.0_PHP4
  3. Apache1.3_CF6.1_PHP5
  4. Apache1.3_CF7.0_PHP5
  5. Apache2.0_CF6.1_PHP4
  6. Apache2.0_CF7.0_PHP4
  7. Apache2.0_CF6.1_PHP5
  8. Apache2.0_CF7.0_PHP5

Of course, we could also run our local server without the ColdFusion MX component, or PHP component at all. For ease, however, we'll just stick with one of the above possibilities. What this means is that for each of the above that you want to run, you'll need to have an httpd.conf file.

If you followed my above guides, than you should already have the Apache 1.3.x configuration files (although with slightly different names). Once we have all eight configurations, we can write batch files to automate most of the process. For getting these up and running. With one click (and maybe just a little renaming), we can have the Web server that we want up and running.

Whatever you may have for Apache 1.3.x, I recommend you create a 'configuration' folder in your DocumentRoot directory (so, c:\home\configuration\ if you've been following along) where you can begin compiling httpd.conf files.

For example, I've obviously followed by own guides, so I have four files thus far.

  • httpd_Apache1.3_CFMX6.1_PHP4.conf
  • httpd_Apache1.3_CFMX6.1_PHP5.conf
  • httpd_Apache1.3_CFMX7.0_PHP4.conf
  • httpd_Apache1.3_CFMX7.0_PHP5.conf

We should also have either one or two php.ini files – one for PHP 4 and one for PHP 5 – that we'll also want to put copies of in this folder.

  • php_Apache_PHP4.ini
  • php_Apache_PHP5.ini

Apache 1.3.x and Apache 2.0.x use the same php.ini files. So, it's not necessary to make one copy each for Apache 1.3.x and one each for 2.0.x.

This done, we can begin connecting to PHP 4 and PHP 5 on Apache 2.0.x.

Hooking up PHP 4.4.2

In a previous guide, we installed PHP 4.4.2 and in yet a later guide moved our installation to the c:\php4\ folder.

Since we've already got PHP 4 working on Apache 1.3.x, most of our setup is already complete. Now it's just a matter of hooking up Apache 2.0.x to recognize it.

First, we'll need to make sure we've got a backup of the httpd.conf file in the C:\Program Files\Apache Group\Apache2\conf folder.

Now open the Apache 2 httpd.conf file. Do a search for LoadModule, and at the end of this section, add the following line. Keep in mind that if you installed PHP 4 to a different folder, you should make that change here as well.

LoadModule php4_module "c:/php4/php4apache2.dll"

Now, do a search for AddType. After the first uncommented line (AddType application/x-gzip .gz .tgz), place the following.

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Finally, add 'index.php' to the DirectoryIndex line, where ever you'd like it be called in the order of things. Depending upon preference, you may also want to add index.htm, since Apache 2.0.x doesn't seem to want to include these.

Save httpd.conf. Now go to the c:\php4\ directory (or where you installed PHP 4) and copy the php4apache2.dll from the sapi folder into the root PHP folder. So, from c:\php4\sapi\ to c:\php4\.

For php.ini, everything should be setup correctly. However, you'll want to verify that the right php.ini file is in place.

Now start Apache2 from the Services panel (or the Apache Services Monitor) and you should find that the description lists PHP 4. If you go to http://localhost/phpinfo.php (if you created this file), you should also find that PHP is up and running.

Make sure both your ColdFusion MX 6.1 and ColdFusion MX 7.0 httpd.conf files have the httpd.conf changes made, and you can switch between either version.

Connecting to PHP 5

Assuming you've already setup PHP 4 for Apache 2.0.x, using the instructions above, moving to PHP 5 is extremely easy. So easy, in fact, that it's scary. Make a copy of any httpd.conf files you may have for PHP 4. For example, the two I have in C:\Program Files\Apache Group\Apache2\conf\ are called httpd_CFMX6.1_PHP4.conf and httpd_CFMX7.0_PHP4.conf.

I'll copy both of these and rename them to httpd_CFMX6.1_PHP5.conf and httpd_CFMX7.0_PHP5.conf. That done open both up and do a search for php4, one file at a time. You'll find php4 three times, in the following line.

LoadModule php4_module "c:/php4/php4apache2.dll"

Which you'll simply change to three '5's.

LoadModule php5_module "c:/php5/php5apache2.dll"

Now save the httpd.conf files. The php5apache2.dll file will already be in this location, so you should be set to go. Make a copy of either one of these, make sure that you're using the right php.ini file, restart Apache2, and verify that phpinfo() gives the correct information.

Wasn't that easy?

Now that PHP 4 and/or PHP 5 are installed ...

Now that we've setup PHP 4 and/or PHP 5 with Apache 2.0.x, it's time to backup the necessary .conf files into our 'configuration' folder.

At this point, you'll have up to ten files in this folder (c:\home\configuration\). Up to eight .conf files and up to two .ini files. I've listed all ten possibilities below.

  • httpd_Apache1.3_CFMX6.1_PHP4.conf
  • httpd_Apache1.3_CFMX6.1_PHP5.conf
  • httpd_Apache1.3_CFMX7.0_PHP4.conf
  • httpd_Apache1.3_CFMX7.0_PHP5.conf
  • httpd_Apache2.0_CFMX6.1_PHP4.conf
  • httpd_Apache2.0_CFMX6.1_PHP5.conf
  • httpd_Apache2.0_CFMX7.0_PHP4.conf
  • httpd_Apache2.0_CFMX7.0_PHP5.conf
  • php_Apache_PHP4.ini
  • php_Apache_PHP5.ini

Now, let's create a blank text file called zblank.txt. Next, we should determine whether we want to have a version that does not run ColdFusion MX. If you want to, read the next section. Otherwise, skip the next section and read the following one.

Removing ColdFusion MX from our configurations

To remove ColdFusion MX, you'll need four more httpd.conf files. Two for Apache 1.3.x and two for Apache 2.0.x, as each has two versions of PHP. Since it doesn't matter which one we take from, just copy the four httpd.conf files that reference CFMX6.1 in their file names.

Now, simply remove the 'Copy of ' and 'CFMXx.y' from the four file names. You'll end up with the following.

  • httpd_Apache1.3_PHP4.conf
  • httpd_Apache1.3_PHP5.conf
  • httpd_Apache2.0_PHP4.conf
  • httpd_Apache2.0_PHP5.conf

There's just a couple of things to remove from each of these conf files. The following block will need to be removed from the Apache 1.3.x files.

# JRun Settings
LoadModule jrun_module "C:/CFusionMX/runtime/lib/wsconfig/1/"
<IfModule mod_jrun.c>
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ssl false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore "C:/CFusionMX/runtime/lib/wsconfig/1/"
JRunConfig Bootstrap
#JRunConfig Errorurl <optionally redirect to this URL on errors>
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc

And this block will need to be removed from the Apache 2.0.x files.

# JRun Settings
LoadModule jrun_module "C:/CFusionMX/runtime/lib/wsconfig/2/"
<IfModule mod_jrun20.c>
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ssl false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore "C:/CFusionMX/runtime/lib/wsconfig/2/"
JRunConfig Bootstrap
#JRunConfig Errorurl <optionally redirect to this URL on errors>
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc

Finally, make sure 'index.cfm index.cfml' is removed from the DirectoryIndex lines in each file.

By allowing our Apache 2.0.x server, and Apache 1.3.x server, to run without checking for ColdFusion MX, we can keep it running quick, even if we decide not to start any versions of ColdFusion MX.

The only thing we have left is hooking up MySQL and PostgreSQL and creating batch files to use these httpd.conf and php.ini files to get the server we want up and running.

So, let the hardest part begin.

Connecting to MySQL and PostgreSQL

Amazingly enough, as long as you already setup MySQL and PostgreSQL for Apache 1.3.x, you're all set to begin using MySQL and PostgreSQL for both ColdFusion MX 6.1, ColdFusion MX 7.0, PHP 4, and PHP 5. This is because ColdFusion MX is handling the SQL requests via the datasources, and PHP is likewise handling it's own requests (via the php.ini file).

Feel free to test this using the PHP files I detailed before (check MySQL connection in PHP | check PostgreSQL connection in PHP) or just using the ColdFusion MX Administrator to check all datasources.

Coming in Part 4 ...

In Part 4, I'll be going over how to create the batch files that we'll need to work with the httpd.conf and php.ini files that we've created. While I could detail it here, better to just put it in it's own article/post, as that makes things much easier (if not for you, then at least for me ;)).

View all of the steps to creating a local Web server, for development.