March 26, 2006
Configuring IIS and Apache for PHP
As I mentioned in a previous post, in order to develop PHP web pages on your local PC you need a web server installed. You basically have two choices: Use a software package to install everything you need or you can install them seperately to get the greatest control over your development environment. For Windows users if you do not have the Professional edition that includes Internet Information Server (IIS) you need to down the Apache web server instead.
Configuring either IIS or Apache can be tricky and somewhat confusing so I did the research for you and give you detailed steps on how to configure either IIS or Apache to work with PHP.
Setting up PHP (for IIS or Apache)
1. Download the latest Windows zip package
2. Extract the files to c:\PHP (PHP folder)
3. Find libmysql.dll and php5ts.dll and copy to c:\windows\system32
4. In PHP folder: find php.ini-dst and make a copy
5. Rename the copy to php.ini
6. Move the php.ini to c:\Windows
7. Open the file in Notepad
8. Find extension_dir = "./" and change to extension_dir = "c:\PHP\ext"
9. Find ;extension=php_mysql.dll and remove semi-colon
10. Find ;extension=php_mysqli.dll and remove semi-colon
11. Create a temp directory (c:\temp)
12. Find ;session.save_path and change to session.save_path = "c:\temp"
13. Save and close Notepad
Configuring IIS
1. Control Panel -> Administrative Tools -> Internet Information Service
2. Right click on Default Web Site -> Properties
3. ISAPI Filters tab: Add PHP filter with executable c:\PHP\php5isapi.dll
4. Home Directory tab:
Click Configuration, Click Add (Mappings tab)
Executable: c:\PHP\php5isapi.dll and Extension: .php
Click OK
Now all .php files will be processed using the PHP library (php5isapi.dll)
5. Documents tab:
Click Add
Default Document Name: index.php
6. Restart IIS
Go to Services (Administrative Tools -> Services)
Select World Wide Web Publishing Service
Click Restart the service button
Configuring Apache
1. Download the Win32 binary (MSI Installer)
2. Run the installer wizard
During install enter "localhost" for Network Domain and Server Name
3. Program Files -> Apache HTTP Server -> Configure Apache Server
Edit Apache httpd.conf file
4. Find LoadModule
Go to the bottom of section and add a new line:
LoadModule php5_module c:/php/php5apache2.dll
5. Find DirectoryIndex
Add to exisiting line:
DirectoryIndex index.html index.html.var
DirectoryIndex index.html index.html.var index.php
6. Find AddType
Add a new line to the bottom of this section:
AddType application/x-httpd-php .php
7. Save and close Notepad
8. Restart Apache:
Program Files -> Apache HTTP Server -> Control apache Server -> Restart
Testing PHP
1. Create an index.php file with this code:
<?php phpinfo(); ?>
2. Save to:
c:\inetpub\wwwroot (IIS)
c:\Program Files\Apache Group\Apache2\htdocs (Apache)
3. Type http://localhost/ and it should look something like this
