Impossible tri-bar

Digital Phenomena - Your first stop for internet consultancy 
PHP4 Installation Overview

Page 9 — Installing PHP4 (Windows)

This section tells you how to do a fresh install of PHP4 on your system, using the CGI version of PHP4. You're not so much installing things as you are just moving things around, so just follow these easy steps:

  1. Go to the "Downloads" area at http://www.php.net/ and select the link for the Windows binaries. This is a zip file, containing pre-compiled binaries, ready to install.
  2. Once you have the file on your hard drive, use your favorite un-zipping tool to extract the contents to, say, C:\php4\ (If you put the files in some other directory, remember to substitute that directory name as the instructions continue).
  3. Take the file called "php.ini-dist", rename it to "php.ini" and move it to C:\WINDOWS\ or wherever the rest of your *.ini files live.
  4. Take the two files "Msvcrt.dll" and "php4ts.dll", and put them in C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files. If your system tells you that you already have "Msvcrt.dll" or it's currently in use, that's fine. As long as you have it, there's no issue.
  5. Forget about the other *.dll files for now.

You'll need to go back to the Apache httpd.conf and make a few modifications to tell Apache what to do with *.php or *.phtml files (and how to do it).

With httpd.conf open in your text editor, find a section that looks like the following:

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/"

You need to add another ScriptAlias line to the end, just like this:

ScriptAlias /php4/ "C:/php4/"

Now find a section that looks like this:

# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
#
#AddType application/x-httpd-php3 .phtml
#AddType application/x-httpd-php3-source .phps

Although the example is now out-of-date, since you'll be using PHP4, you get the idea. This is the area where you say "for all files ending with [whatever], consider them to be of [whatever] type." If you want to create your own file extension for PHP files, like .joe (really, you can), add .joe after the .php and .phtml in the first AddType line.

The section should now look something like this:

# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
#
#AddType application/x-httpd-php3 .phtml
#AddType application/x-httpd-php3-source .phps

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

TIP: If you want to parse *.html files as PHP, just add the file extension to the list in your AddType line, so that it ends up looking like this:

AddType application/x-httpd-php .php .phtml .html

And now one last modification. Find a section like this:

#
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#

You need to include an Action line for your new file types, so that they automatically get sent through the PHP parser. So add this:

Action application/x-httpd-php /php4/php.exe

I know it looks weird -- the missing drive letter, the slashes are backwards, there aren't any quotation marks -- but this is how you do it. That /php4/ comes from the ScriptAlias line at the beginning of the file, so Apache knows that /php4/ really equals C:\php4\ ("C:/php4/" == "C:\php4\" in Apache world). The Action line says, basically, "when you find a file type that ends in *.php or *.phtml, meaning it's of the type application/x-httpd-php, go to ScriptAlias and find a file called php.exe, run it, and spit out the output."

Save your httpd.conf file and start Apache again. If Apache is still running from the original installation, stop it first, then restart it. Provided there are no issues on startup, you should now be ready to test your installation.

next page»


|Home|About Us|Services|Search|
|Software|Products|Support|Links|Latest|
W3C validatedW3C validated CSSCompatible with all browsers