PHP DevCenter
oreilly.comSafari Books Online.Conferences.


PHP Admin Basics

Installing PHP on a Windows System


PHP, while originally designed and built to run on Unix, has had the ability since version 3 to run on Windows. That includes 9x, ME, NT, and 2000. In this article I'm going to go through the process of installing PHP on Windows and explain what you should look out for.

On Windows, as on Unix, you have two options for installing PHP: as a CGI or as an ISAPI module. The obvious benefit of the latter is speed. The downside is that this is still somewhat new and may not be as stable. But, before you do anything, you have to do some prep work, which is pretty simple. Once you've downloaded and unzipped the Windows binary version of PHP, you have to copy php4isapi.dll from the sapi/ directory to WINNT/system or WINDOWS/system directories. You'll also probably want to move php.ini-dist from your installation directory to the WINDOWS/ directory and rename it to php.ini, if you plan on changing any of the precompiled defaults. Now you're ready to go, regardless of whether you use PHP as a CGI or ISAPI module.

For NT/2000, you'll need to tell IIS how to recognize PHP. Thanks to the wonders of GUI, this can easily be accomplished with a few mouse clicks. First, fire up the Microsoft Management Console or Internet Service Manager, depending on whether you're using NT or 2000. Click on the Properties button of the web node you'll be working with. In this example we'll use Default Web Server. Click the ISAPI Filters tab and then click Add. Use php as the name and in the path put the location of php4isapi.dll, which should be C:\WINNT\system\ in this example.

Configuring IIS to recognize PHP.

Configuring IIS to recognize PHP.

Under the Home Directory tab, click the Configuration button, then click Add for Application Mappings. Use the same location of php4isapi.dll as you did with ISAP Filters and use .php as the extension. Here comes the caveat!! As a test, I tried using as my path the temporary location of php4isapi.dll, which was in the install directory on my desktop. Windows 2000 popped up a wonderfully annoying little box telling me I'm stupid and I should go dunk my head in the sand. OK, so it wasn't quite that wordy, but that's how I took it. Apparently Windows 2000 and IIS require App Mappings to be under the WINDOWS dir at least. So keep that in mind if you don't like sand up your nose.

Now, click OK on the Properties dialog. The next thing to do is start and stop IIS. This isn't the same as pushing the stop and start buttons on the Management Console. You should go to a command (or cmd, as it were) window and type net stop issadmin. Wait for it to tell you what it's doing, as if you were nosy enough to care, and then type net start w3svc. Why they didn't make it net start iisadmin is beyond me. But I'm a Unix guy, and logic seems to be my downfall here. But I digress...

So now you have PHP installed as an ISAPI module on Windows! Aren't you happy? Probably not, because you probably don't believe me. Well, if you need proof just go to C:\inetpub\wwwroot\ and put a file called test.php in there. Inside that file put the following code:


Then pull up test.php in your browser. If you see the PHP Info page, it worked! Now this probably goes without saying, so I'll say it. You have to pull up test.php as a web page in the browser using http://. If you give the path for the file using file://, then you'll get a raw output of the code, which is no fun.

The PHP Info page.

The PHP Info page indicates success.

On Windows 9x/ME, you're somewhat restricted to PWS (Personal Web Server). Of course there are alternatives such as OmniHTTPd, but we don't have all day here! Anyway, this is far simpler. It's mainly just a matter of a registry entry.

After you've moved php.ini and php4ts.dll to the appropriate directories, you should open up your favorite registry editor. At this point I note the obligatory warnings about fooling around with the registry, blah, blah, blah... In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map, you'll want to add an entry with the name of .php and a value of C:\\Program Files\\PHP\\php4isapi.dll.

Next, go start up the PWS Manager. For each of the directories that you want to make PHP aware, you have to right-click on that directory and check the executable box.

Now you're ready. Perform the same test (test.php) as I described above, and have fun making all those ASP cronies jealous at the the guru-like glow that surrounds you!

Darrell Brogdon is a web developer for SourceForge at VA Linux Systems and has been using PHP since 1996.

Read more PHP Admin Basics columns.

Discuss this article in the O'Reilly Network PHP Forum.

Return to the PHP DevCenter.


Valuable Online Certification Training

Online Certification for Your Career
Earn a Certificate for Professional Development from the University of Illinois Office of Continuing Education upon completion of each online certificate program.

PHP/SQL Programming Certificate — The PHP/SQL Programming Certificate series is comprised of four courses covering beginning to advanced PHP programming, beginning to advanced database programming using the SQL language, database theory, and integrated Web 2.0 programming using PHP and SQL on the Unix/Linux mySQL platform.

Enroll today!

Sponsored by: