Results 1 to 1 of 1

Thread: Installing and Running PHP 5 Under IIS 5

Threaded View

  1. #1

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Arrow Installing and Running PHP 5 Under IIS 5

    By the end of this tutorial you should be able to run PHP scripts through a Microsoft Internet Information Services web server.
    This tutorial uses IIS version 5.1, as shipped with Windows XP Professional. The IIS 6 administration console is different but the steps in this tutorial may be adaptable to it.


    Prerequisites

    You will need to download the following:
    1. Latest version of PHP 5. Select the first zip package listed under "Windows Binaries".


    You will need IIS installed. If this is not already present in your Windows installation, you can do so by heading to Control Panel, Add or Remove Programs, Add/Remove Windows Components. Scroll down to "Internet Information Services (IIS)" and click the checkbox beside it.

    Name:  iis-install.png
Views: 3378
Size:  33.0 KB

    Click Next and follow the remaining steps. You will need to restart your computer to complete the installation.


    Installing PHP

    First, create a directory for PHP (e.g. c:\php\).
    Extract the contents of the zip file into this newly created directory.

    Next, make a copy of the file php.ini-recommended and name the copy php.ini.
    This file contains all of the configuration settings for PHP. You do not need to alter any settings to begin with.


    Configuring IIS

    Finally, we need to set up IIS to handle PHP scripts.
    Open the IIS administration console from Control Panel, Administrative Tools, Internet Information Services.

    You should see a two-paned window. In the left-hand pane, click the + sign next to your local computer name, and the + next to Web Sites. You should then see Default Web Site. Right-click this and choose Properties.

    Name:  iis-properties.png
Views: 3335
Size:  28.2 KB

    (If you already have another web server, such as Apache, running, you should at this point change the TCP Port setting from 80 to an alternative such as 800.)

    Click the ISAPI Filters tab. By default, there'll be no filters installed. Click the Add button. In the Filter Name field, type PHP. Then, click the Browse button. Browse to the folder in which you extracted the PHP files, then the /ext directory, and then select php5isapi.dll. Click OK and then OK to add the filter.

    Name:  isapi-filter-1.png
Views: 3140
Size:  9.2 KB

    Name:  isapi-filter-2.png
Views: 3239
Size:  12.9 KB

    Next, go to the Home Directory tab.
    Under Execute Permissions, make sure it is set to "Scripts only". Click the Configuration button to its right.

    Here, we map the .php file extension to the PHP interpreter.
    Click the Add button. In the Executable field, browse to php5isapi.dll as before. In the Extension field, type .php. Leave the other settings as default and click OK. You'll now see it listed under the other mappings.

    Name:  isapi-mappings.png
Views: 3167
Size:  22.4 KB

    Click OK and OK.

    The last thing thing to do in this dialogue box is to enable a PHP directory default file. Go to the Documents tab, click Add, and type index.php. You may use the arrow buttons to position this at the top if you wish.

    Name:  iis-default.png
Views: 3128
Size:  32.1 KB

    Click OK (and OK if a subsequent dialogue box opens) and Apply, OK.


    Now, we need to restart IIS. Open up a terminal window by going to the Run dialogue (Win+R or Start Menu, Run) and typing cmd.

    Stop IIS:
    net stop iisadmin

    Then start it again:
    net start w3svc

    Name:  cmd-iis-restart.png
Views: 3210
Size:  27.0 KB

    You should now have a working setup. Let's test it out.


    Testing

    Create a file in your wwwroot directory (usually C:\Inetpub\wwwroot\) called phpinfo.php.

    In this file, type the following code:
    PHP Code:
    <?php
      phpinfo
    ();
    ?>
    Now, navigate to this file in your browser.
    http://localhost/phpinfo.php

    You should see a page like the following:

    Name:  phpinfo.png
Views: 3048
Size:  35.2 KB

    If you do, congratulations: you've successfully set up PHP under IIS.


    If you have any problems, make a post in the PHP forum and we'll be happy to assist.
    If you have any suggestions or feedback regarding this tutorial, you're welcome to reply here or send me a private message.


    Copyright © 2007. Unauthorised reproduction strictly prohibited.
    Last edited by penagate; Dec 6th, 2007 at 06:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width