Installing PHP with Microsoft Internet Information Services (IIS)

This article explains how to install PHP with Microsoft Internet Information Server (IIS) web server on Windows through either the automatic or manual installation. Note that you cannot customize the automatic installation with as many options as the manual installation (for example, no PHP extensions).

First, download PHP. If you want to use the automatic installation, go to the “Windows Binaries” and select the EXE package and then the download mirror closest to you. If you want to use the manual installation, go to “Windows Binaries” and select the ZIP package and then the download mirror closest to you.

Automatic Installation
Once you start the installation and agree to the license, the installation will display two install options: standard and advanced. The standard installation defaults to a minimum set of required options, while the advanced installation gives you more options and choices for your installation.

  1. Select either the standard or advanced installation option. After selecting your installation option, the Server Type dialog appears (see below):
The Server Type dialog. box. Select Microsoft IIS 4 or higher.
Figure 1. The Server Type dialog. box.
  1. Select the Microsoft IIS 4 option or higher and click Next.
  2. Choose the file extension for your PHP scripts. (Note: Most developers select the .PHP extension for their PHP scripts.)
  3. The installer will then complete its installation.
  4. Edit the PHP.INI file for the cgi.force_redirect directive. See the CGI Mode section in the manual installation instructions below.
  5. Test your PHP installation.

Manual Installation
Use the following steps to install PHP manually.

When you have finished downloading the PHP ZIP file, unzip the files into a folder. For this article, I unzipped the files to C:\drive (but you can unzip your files to any location or folder).

Note the PHP ZIP file unzips and creates a folder based on the PHP release you downloaded. For example PHP release version 4.2.3 would unzip to the following folder C:\php4.2.3-Win32. To make future upgrades of your PHP installation easier, I recommend that you rename the installation folder to C:\php\. For this tutorial, I will refer to the C:\php\ folder.

CGI or ISAPI? When using IIS, you can choose to run PHP in a CGI mode or in an ISAPI mode . While the ISAPI module performs faster than the CGI module, it hasn’t been tested in a production environment and is known to cause problems, such as system crashes (although some users report no problem). Therefore, if you intend on using PHP in a production environment, I recommend that you use the CGI mode until the ISAPI module is more stable.

In this article, I will cover installing both options. Before beginning, you must copy the php settings into the C:\WIINT directory. Find the settings files in the PHP directory: php.ini-dist and php.ini-recommended. Normally, you would use the php.ini-dist file; however, the php.ini-recommended file has a simpler layout, contains fewer settings, and allows PHP to run faster. Depending on which file you choose, copy it to the C:\WINNT folder and rename it to php.ini.

CGI mode. Follow the instructions below to install PHP in the CGI mode.

  1. Edit the following lines in the php.ini file:cgi.force_redirect = 0
    cgi.redirect_status_env = ENV_VAR_NAMEThese lines are security settings. If you leave these lines as they are, it prevents PHP from running in CGI mode. To enable PHP, you can either set a system variable (ENV_VAR_NAME) that PHP will look up before it runs or you can force PHP to run with cgi.force.redirect = 0.
  2. Set up IIS so that IIS will serve PHP scripts.
    1. Open IIS in the Microsoft Management Console MMC (usually Start > Administrative Tools > Internet Services Manager) and select a web server and website instance. (If you have multiple instances and wish to run PHP on all of the instances, you may install PHP to the master instance—Default Web Site.)
        1. Right click the website instance, select properties from the context menu, and click the Home Directory tab.
        2. Click the Configuration button and the Add button.
          1. For the Executable, use the browse button or type the path to your php.exe file within the PHP folder. (For instance, in this article, the path is C:\PHP\PHP.exe.)
          2. In the Extension Type, type the file extension that the server should use to refer to PHP scripts (this is commonly the .php extension).
      1. You should see the following:
      The Add/Edit Application Extension Mapping dialog box. Your settings should appear as shown.
      Figure 2. The Add/Edit Application Extension Mapping dialog box. Your settings should appear as shown.
      1. Click OK, Apply, and OK buttons to complete the settings.
      2. You are now ready to test your PHP installation.

      ISAPI mode. If you are going to install PHP in an ISAPI mode, be aware that you must copy some DLL files to get PHP to function correctly. PHP uses several DLLs, such as the PHP4TS.dll file and DLL files in both the DLL and extensions folders. I will cover DLLs in the extensions folder later in this article. For now, you must work with the PHP4TS.dll file and DLL folder files. Use the following steps.

      1. You must make the files available to the ISAPI module. I recommend that you copy the files into the C:\WINNT\SYSTEM32 folder. While you may copy the files into the C:\PHP\SAPI folder, putting the files in the C:\WINNT\SYSTEM32 folder is preferable.
      2. Open the Microsoft Management Console (MMC) for IIS web server for your selected web server and website. (The same options apply here as in the CGI installation listed above).
      3. Open the Properties dialog box, select the ISAPI tab, and select Add.
        • In Filter Name, add the name of the ISAPI filter. (For this article, I entered: “PHP”.)
        • In the Executable field, either use Browse or type the path to C:\PHP\SAPI\PHPISAPI.dll
          You should see the following:
      The Filter Properties dialog box. Your settings should appear as shown.
      Figure 3. The Filter Properties dialog box. Your settings should appear as shown.
      1. Click the OK button and select the Home Directory tab and the Configuration button. The procedure here is identical to the CGI installation listed above.
        • In the Executable, use Browse or type the path to your PHP folder and the PHP4ISAPI.dll file (for this article, it is C:\PHP\SAPI\PHP4ISAPI.dll).
        • In the Extension type, enter the file extension that the server should use to refer to PHP scripts (this is most commonly the .php extension).

      You should see the following:

      The Add/Edit Application Extension Mapping dialog box. Your settings should appear as shown.
      Figure 4. The Add/Edit Application Extension Mapping dialog box. Your settings should appear as shown.

      • 5. Click OK, Apply, and OK to complete the settings.
      • 6. Stop and restart the web server. To do this, use the Services utility in Control Panel within Administrative Tools (Start > Programs > Administrative Tools > Services or Start > Settings > Control Panel > Administrative Tools > Services). Then right click the IIS Admin Service and select Restart. You may also use the Command console to start/stop the web server, as follows:
      • a. To stop the web sever enter: Net stop iisadmin
      • b. To restart the web server enter: Net start w3svc
      • 7. When the web service has restarted, open the ISAPI tab as described in steps 2 and 3 above.
      • 8. Ensure that the ISAPI has loaded correctly. The ISAPI should be green, not red; red indicates that the ISAPI has failed to load. If the ISAPI has not loaded correctly, ensure that your paths to the ISAPI files are correct and that you copied the DLL files into the correct locations. If the ISAPI loads correctly, you are ready to test your PHP installation.

      Testing Your PHP Installation
      To test your installation, you’ll create and run a simple PHP script.

      • 1. In the IIS webroot (typically at C:\INETPUB\WWWROOT\), create the following script (You can set up a PHP site in Dreamweaver MX, or you can use a text editor such as Notepad or any editor you wish.):

      <? phpinfo(); ?>

      • 2. Save the script as test.php in your webroot.
      • 3. Open the file your browser (remember that the server must serve this file, so you must use a local URL such as: http://localhost/test.php, the URL is based on where you saved your test.php file). The following appears:

        testing PHP
        Figure 5. Testing your PHP configuration.
        Installing PHP extensions
        You can extend PHP functionality by using PHP extensions. PHP extensions allow PHP to process XSLT and connect to Oracle 8. PHP comes precompiled with pre-built extensions so you can use MySQL, ODBC, sessions, and XML right after installing it.To use an extension, set it up as follows.

        • 1. Open the PHP.INI file and locate the following line.

        extension_dir = ./

        This line indicates the folder where the PHP extension DLL files are located. Edit this line to:

        extension_dir = C:\php\extensions

        • 2. Select from the PHP extension choices. Note that some of these files depend on other software to work correctly (such as the Oracle 8 extension). Consult the PHP documentation to see what additional software (if any) is required.
        • 3. See an example for loading an extension in the following commented out line:


        Uncomment the line, as follows:


        • 4. Save your changes.
        • 5. Browse the PHP test page in your browser.
        Figure 6. Testing the PHP page. The page should appear as shown in this figure.
        For all PHP extensions, I recommend that you consult the PHP documentation to learn how you can best use the extensions and set them up securely in your web applications.Using MySQL and PHP
        I mentioned earlier in the article that PHP is precompiled with a pre-built MySQL extension. While setting up a MySQL database server and the MySQL PHP extension correctly and securely is beyond the scope of this article, I recommend the following resources:

        This article introduced you to installing PHP on Windows with the IIS web server. I showed how to install PHP with either the more flexible manual installation or using the automated Windows installer.

      This blog is taken from Dreamweaver Article

MySQL ASP Connection (Using ODBC)

Hi, Sometimes ago I came around a problem.

The problem was I want to connect to my MySQL Database from ASP ( Active server pages) code. MySQL can be easily connected from PHP (Hypertext Pre Processor). But with ASP it is some thing else.

Then I found a way to solve the problem:

1. If you donot have mysql istalled in your machine then you can istall mysql 5.0 form and MySQL 4.1. From

2. Then download the suitable version of mysql-odbc-connector (3.51 or 5.1) 

After downloading this connector install it. You can check it is installed successfully or not from START-> COntrol Panel->Administrative Tools ->Data Sources (ODBC).
It will open ODBC Datasource Administrator. Click ADD. You will find MYSQL ODBC 3.51 or 5.1 Driver.
If you find it then it is installed correctly and ready for use.

3. If you istall mysql successfully then craete a table is the database (Use your own database).
e.g. CREATE DATABASE my_tst;

then Create a tbale:
CREATE TABLE my_test_table(id INT(3), name VARCHAR(20));

Then Insert some values in the db:
INSERT INTO my_test(id,name) VALUES(1,’udaybhanu’);
INSERT INTO my_test(id,name) VALUES(2,’qwer’);
INSERT INTO my_test(id,name) VALUES(3,’asdf’);
INSERT INTO my_test(id,name) VALUES(4, ‘zxcv’);

4. Then if you have IIS Installed on the server then create a virtual directory to run ASP ( If you have it already then leave this step.)

5. Then create a file named connect-mysql.asp and put the contents written below.

Dim sConnection, objConn , objRS

‘define connection string, specify database driver and location of the database

sConnection = “DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; DATABASE=tst; UID=root;PASSWORD=root123; OPTION=3”
Set objConn = Server.CreateObject(“ADODB.Connection”)

Set objRS = objConn.Execute(“SELECT id, name FROM tst1”)
While Not objRS.EOF
Response.Write objRS.Fields(“id”) & “, ” & objRS.Fields(“name”) & “<br>”

Set objRS = Nothing
Set objConn = Nothing

Now point your Internet Explorer to the path of the script (e.g. http://localhost/asp/connect-mysql.asp)

Then it will display all the id and names which are on the database.

And the problem is solved 🙂

Hope this blog will help you to solve your problem also.