This guide will show you the necessary steps to install and configure PHP 5.2.1 (5.x)Â on Windows server 2003 using IIS 6 as the web application server. This guide does not show you how to install Windows server or install IIS, just the config steps neccesary after install.
Here are the steps;
- Install PHP
- Configure PHP
- Configure IIS
- Test the install
Here we go…
Step 1: Install PHP
- Get the latest version of PHP from php.net. Get the latest binaries but not the Windows installer as we are going to do all the dirty work by hand… Don’t worry, there’s not too much…
- Get the latest version of the PECL Modules too if you need these specific extensions for you application. If you’re not sure, get them anyway and wait until later in the install before loading them onto your server…
- Create a directory on the root of your server system drive in which to extract the PHP files. I use C:\PHP (tada!).
- Unzip the binaries into the C:\PHP folder. You will now have a directory structure that looks like this:
This is the basic directory structure as of version 5.2.1.
- If you know you need the PECL extensions you can extract those now. If you’re not sure you can come back to this point later and extract them. Either way, extract the files into;
Step 2: Configure PHP
- In your C:\PHP directory you’ll find a file named php.ini-recommended. Rename or copy and rename that file as php.ini.
- Open php.ini up in your favorite text editor and preform the following edits (I’ve listed them in order as of PHP version 5.2.1)
- extension_dir = “c:\php\ext\”
- cgi.force_redirect = 0
- browscap = “c:\php\extras\php_browscap.ini”
- session.save_path = “c:\php\sessions\”
- Install a browscap.ini file. This is optional but prefered soÂ right mouse click and choose Save Target As…Â here to get theÂ php_browscap.ini that I’m using or else search and find the one you want. Then copy it to c:\php\extras\php_browscap.ini (rename it from .txt to .ini).
- Create a directory for the PHP session files. I chose to use C:\PHP\SESSIONS\ initilally. Create it here to start and when the install works then move it onto a different drive if you want.
- Add C:\PHP to your servers path environment variable.
- Right click My Computer, Properties and select the Advanced tab, then click on the Environment Variables button.
- Select the Path variable and click the edit button.
- Add C:\PHP; to THE BEGINING OF THE ENVIRONMENT STRING
- Click on OK.
- Add New variable PHPRC to the Environment Variables.
- Click the New button
- Variable name is PHPRC
- Variable value is c:\php
- Click OK.
- Clcik OK back to desktop.
Step 3: Configure IIS
Add PHP ISAPI Extension
- Open IIS Manger
- In the left pane select Web Service Extensions
- Click the link Add A New Web Service Extension…
- Extension name is PHP 5.2.1 Extensions (Name can be whatever you want)
- Click the Add… button
- The path to the file is C:\PHP\php5isapi.dll
- Check the Set Extension Status Allowed… checkbox
- Click OK to finish
Add .PHP Extension
- Right click on Web Sites and choose Properties
- Select the Home Directories tab
- Click on the Configuration button
- On the Mappings tab click the Add… button
- Executable browse to C:\PHP\php5isapi.dll
- Extension is .php
- Select Limit to: and type GET,POST,HEAD
- Check Verify that file exists and click OK. Then OK again to get back to the Home Directory tab of the Web Sites properties dialog
- Set Execute Permissions to Scripts only
REBOOT THE SERVER!
Step 4: Test the Install
- Download this test file and copy it to a working website folder on your web server. i.e. yourdomain.com/info.php (rename it from .txt to .php)
- Open the url in a browser http://yourdomain.com/info.php
- If the install is good you will see something that starts off like this;
Please look at the 6th entry, the path to the php.ini file. If it’s your path, you have a good install and you can continue with the rest of your setup for the particular PHP system you are putting in. If it’s not your path, go back to the Environment Variable setting and make sure you put the variable at the FRONT of the path string.
That’s about it, good luck!