Installing PHP 4.2.0 and configuring with Apache 2.0
The installation file that comes with PHP 4.2.0 does not come with instructions on how to configure with Apache 2.0 but is still a useful reference. Also for everything you ever need to know, want to know, and more then you can ever know about PHP read over the documentation at http://www.php.net/manual/en/.
1) After you have downloaded the zip file. Unzip all of these files to the C:\ directory. This will create a directory structure like: C:\php-4.2.0-Win32. Rename this folder to C:\PHP
2) Copy the file C:\PHP\php.ini-recommended file to your windows folder: c:\winnt or c:\windows.
3) Rename this file (php.ini-recommended) to php.ini once you have placed it within the windows folder. You can rename the file with Notepad. Since the php.ini file is often used I like to place a shortcut to it on my desktop.
4) Copy the file C:\PHP\php4ts.dll file to your windows system folder: c:\winnt\system32 or c:\windows\system (for XP and ME it's the windows\system folder).
We now need to edit both the PHP.ini file and the Apache httpd.conf file.
Open up the httpd.conf file that we where working with when we first installed Apache with Notepad. Look for a block of LoadModule commands (this is located near the beginning of this file). Then insert the following line right after all the the other LoadModule commands:
LoadModule php4_module c:/PHP/experimental/apache2filter.dll (Make sure to use forward slashes for this path instead of Back Slashes).
Please note that you must use the apache2filter.dll and not the php4apache.dll. With earlier versions of PHP (before 4.2.0 and Apache 2.0 you do however use the php4apache.dll). This is an important change to keep in mind when using earlier versions of Apache with PHP.
We have to add one last item to the httpd.conf file before where done with it.
Add the following Line to your httpd.conf file (somewhere after the LoadModule command we just added);
AddType application/x-httpd-php .php
Next Edit the PHP.ini File.
For now all we have to add is the 'doc_root' path (Search the file for doc_root to find it faster). Add the path to the htdocs folder. This path will be something like: C:\Program Files\Apache Group\Apache2\htdocs so that the line now looks like:
doc_root = C:\Program Files\Apache Group\Apache2\htdocs
That should be it. At least it should be enough so that PHP will be running in conjunction with the Apache web server. To test this try the following.
Create a file named PHPInfo.php. Include the following in that file:
Then add this file to your htdocs folder. Open up a browser and type in the following URL: http://localhost/PHPInfo.php If everything went successfully you'll see a long list of all your PHP settings and server information. When starting Apache you should also see a small note that the PHP 4.2.0 module has loaded, also when your viewing the 'Apache Service Monitor' you should see a small note at the bottom indicating that PHP 4.2.0 is running.
On the next page we'll go into some exercise's and fun stuff to do with PHP and Apache.
|» Level Advanced|
Rating: 9 Votes: 108
|Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services.|
|Download the files used in this tutorial.|
|Download (30 kb)|
|More help? Search our boards for quick answers!|