Since thesitewizard.com uses PHP scripts for various purposes, I find it convenient to have my own copy of PHP on my computer so that I can test my scripts offline, instead of having to test and debug them while connected to my ISP. If you have to pay phone and ISP fees for your Internet connections, you may also find this route a cheaper alternative. You will still have to do some testing online, but at least most of the bugs would have been ironed out by the time you upload the script.
Here are the steps you need to install and configure PHP 3 on Windows.
Note that this article deals with the installation and configuration of PHP3 (ie, version 3.X of PHP). If you want to install later versions of PHP, please read one of the following articles instead:
You can obtain the PHP binaries (executables) for Windows from http://www.php.net/.
This is extremely easy. Simply make a directory somewhere on your hard disk. For example, you could create a subdirectory called c:\php3 and unzip all the files into that directory. The examples in this guide assume that you have used that particular directory.
Your c:\php3 directory will contain a file called "php3.ini-dist". Copy that file into your windows directory (C:\WINDOWS in most systems), and rename it to "php3.ini".
Open C:\WINDOWS\php3.ini with a text editor (eg, Notepad) and search for the string "extension_dir". The default value is probably "./". Change that to the directory into which you installed PHP. If you used the values suggested above, the line should now read
extension_dir = "c:/php3"
This determines the place where PHP looks for extensions like graphics drawing, database support and the like.
If you need such extensions, you will need to enable them separately. You can find these in the section "Dynamic Extensions" (search for it). So if, for example, you need GD support (for drawing graphics and images), you need to uncomment (remove the preceding semicolon, ";" from) the line
If you don't know what all these extensions do, simply set the extensions_dir variable for now.
One way to test your scripts is to install Apache on Windows as well. Then all you would have to do is to put your script in the web directory and access it via a browser connected to your local server.
You can find instructions on installing and configuring Apache from my article How to Install and Configure Apache on Windows at https://www.thesitewizard.com/archive/apache.shtml
Skip this step if you are not installing Apache. The first thing you'll need to do is to edit your Apache configuration file, httpd.conf. If you installed Apache into the default directories, you can find that file in "c:\Program Files\Apache Group\Apache\conf\"
Search for the portion of the file which has the ScriptAlias section. Add the following line after the ScriptAlias for "cgi-bin":
ScriptAlias /php3/ "c:/php3/"
Apache needs to be configured for the PHP MIME type. Search for the "AddType" comment block explaining its use, and add the following lines after it:
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .php
AddType application/x-httpd-php3 .phtml
You can of course add whatever extensions you want Apache to recognise as PHP scripts.
Next, you will need to tell the server to execute the PHP executable each time it encounters a PHP script. Add the following somewhere in the file, such as after the comment block explaining "Action":
Note: the "/php3/" portion will be recognised as a ScriptAlias and the value you set earlier will be substituted in its place.
Use a text editor and type the following script for testing purposes.
Save the file and run PHP with the file as a parameter. For example, if the file was saved as "test.php3", you might use the following command line:
You should get a HTML file with lots of information about your PHP setup.
Place the script given in the step above in your htdocs directory, and use your usual method of accessing your web files to access it. You should get the same output as the step above.
Remember also to download the entire PHP documentation set from the PHP website. You should also check up this site often (or just sign up for the free newsletter) for more PHP tutorials and information.
Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.
This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.
It will appear on your page as: