PHP DevCenter

oreilly.comSafari Books Online.Conferences.

We've expanded our LAMP news coverage and improved our search! Search for all things LAMP across O'Reilly!

Search
Search Tips

advertisement

Listen Print Subscribe to PHP Subscribe to Newsletters
PHP Admin Basics

Installing PHP on a Windows System

12/14/2000

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:

<?php
         phpinfo();
 ?>

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.

 




Tagged Articles

Post to del.icio.us

This article has been tagged:

windows

Articles that share the tag windows:

Rolling with Ruby on Rails (57 tags)

Best Windows Admin Downloads (54 tags)

The Ultimate Free Windows Toolkit (31 tags)

Inside Samba: Windows Sharing for the Mac (28 tags)

Automating Windows Applications with Win32::OLE (27 tags)

View All

php

Articles that share the tag php:

Understanding MVC in PHP (477 tags)

The PHP Scalability Myth (123 tags)

The Dynamic Duo of PEAR::DB and Smarty (53 tags)

PHP Form Handling (43 tags)

Very Dynamic Web Interfaces (39 tags)

View All

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com