Quantcast

Installing PHP on IIS 5.1 (Windows XP Pro)

Get the WebProNews Newsletter:
[ Business]

Before we begin any installation steps, the first thing we will need to do is download the PHP zip file from PHP.net (www.php.net/downloads.php). The version available at the time of this publishing is 5.1.4.

Prerequisite: IIS (web server) installed. Click here for tutorial.

The first step is to extract all of the files from the downloaded zip file into C:\PHP (create the folder if it doesn’t already exist). You may choose a different location, although it is not recommended. The path must NOT have spaces, for example, you cannot use C:\Program Files\PHP. Some web servers may not be able to handle the path name and will fault.

PHP 5 includes a CGI executable, a CLI executable as well as the server modules. The DLLs needed for these executables can be found in the root of the PHP folder (C:\PHP). php5ts.dll needs to be available to the web server. To do this, you have 3 options:

1. Copy php5ts.dll to the web server’s directory (C:\inetpub\wwwroot). 2. Copy php5ts.dll to the Windows system directory (C:\windows\system32). 3. Add the PHP directory path to the environment variables PATH.

We will go with option 3, because we would like to keep all of our PHP install files in the same location, for easier cleanup later, if needed. Let’s proceed…

Instructions on how to put C:\php in env variables PATH.

First we want to open System Properties. There are two ways to get to System Properties. Either way will work.

1. Right-Click on My computer and choose “properties”.

2. Go to Control Panel, and select “System”.

Once here, we want to select the Advanced tab. In the Advanced tab, click the “Environment Variables” button. There are two sections in the Environment Variables window, User Variable and System Variables. We will be using System Variables. Scroll down in System Variables until you find the variable PATH. Highlight that line and the select Edit below the System Variables window. We will only be adding to the Variable Value. BE CAREFUL HERE. You do not want to delete anything on this line. Simply find the end of the line and add a semi-colon ( ; ) if there is not one already. After the semi-colon, type: C:\PHP and then hit OK. Now click OK on the Environment Variables window.

Finally click OK on the System Properties window and we are done with this part.

Now we must restart the computer to make the Environment Variables changes come into play. We cannot simply log off and log on, you must restart.

The next step is to set up a config file for PHP, php.ini. In C:\PHP you will find two files named php.ini-dist and php.ini-recommended. We will use php.ini-recommended for this install, and all you need to do is rename it from php.ini-recommended to php.ini.

1. doc_root = C:\inetpub\wwwroot

2. cgi.force_redirect = 0

Now PHP is installed, lets move on to preparing our IIS to use PHP.

Configure IIS to use PHP.

1. Open IIS

2. Under Home Directory: Set “Execute Permissions” to “Scripts Only”

3. Click on configuration..

a. Click Add

b. Set “executable” to C:\PHP\php5isapi.dll

c. Set “extension” to .php (don’t forget to include the . )

d. Click OK

e. Click Apply, then OK. Under ISAPI Filters

a. Click “Add”

b. Set Filter Name to PHP

c. Set Executable to C:\PHP\php5isapi.dll

d. Click OK.

e. Click Apply, then OK. Restart the Web Server

Now we want to test PHP on our system. To do this, we will create a file called phpinfo.php and it will be used to display all of the PHP info from our system in our web browser.

1. Open Notepad and type: <?php echo phpinfo(); ?>

2. Save the file as phpinfo.php and select the file type ‘All Files’ (Important: do not save the file as .txt, as it will not work).

3. Move the file into C:\inetpub\wwwroot

4. Open your web browser and type: http://localhost/phpnfo.php

5. Your browser should display a lot of PHP information.

Congratulations! PHP is now installed and configured on your machine. You can now start building dynamic web pages. For more tutorials visit http://www.StudioThreeHundred.com

Chris Alexander is an IT Professional for a large corporation as well as a freelance web designer. Read more about him at http://www.studiothreehundred.com

Installing PHP on IIS 5.1 (Windows XP Pro)
Top Rated White Papers and Resources
  • AgentOrange

    Hi Chris,

    Thanks for this easy and compprehensive tutorial. I’ve succesfully installed PHP in my IIS5.1. I’ve created a discussion forum using PHP however when i run my .php page its not updating the access database that ive created for it. Am still a newbie in php please help.

  • ramesh babu

    excellent article

  • Shahul Hameed

    Thanks for this posting..it really helps for beginners, and its complete. Keep up the good work

  • Adnan Abbasi

    Hi Chris, Excellent to the point tutorial, but I did everything you said in your tutorial, but when I try to open phpinfo.php in the browser it gives me HTTP 500 error. Could it be something else I need to check. I have no idea as to what could be wrong. Please help, thanks.

    Regards,

    Adnan

    • Bert

      Hello Cris

      I’m having the same problem as Adnan. Could you inform me about what to do to solve this problem?

      Thanks in advance,

      Bert

  • Adnan Abbasi

    Hi Chris,

    The configuration that you talk of works when I tried it on my home computer and now I will configure it on my work computer. Thank you for this thorough and to the point tutorial.

    Regards,

    Adnan

    • jim

      I am having the same problem that the php.ini file is not being read. I have PHP up and running on N:\php, not the windows directory. However when I run phpinfo() I get:
      Configuration File (php.ini) Path = C:\WINDOWS
      Loaded Configuration File = (none).

      Like you Adnan, I need the config file to run mysql. So what was the configuration that solved your problem?

      Thanks,
      Jim

  • http://lab.bcb.iastate.edu Yves Sucaet

    While I can get the phpinfo() command to work, none of the enabled extensions seem to work. In fact, even the extension_dir parameter points to the wrong location (c:\php instead of c:\php\ext). So the php.ini file seems to be bypassed all together. Are there any registry settings one can check? Any parameters that can be passed to the .dll file? PHP is not really useful to me without the MySQL or GD extensions enabled. Has anybody else experienced this problem and know how to solve it?

    Much obliged!

  • Guest

    thanx

  • Guest

    The subject says it all i need help on installing php i alraedy have sql server and iis running on my windows xo pro machine

     

    thanks a million 

  • Guest

    this post is a big fuck

    i tried all the steps but php is a shit asshole is not working….

    • http://www.prtc.net/~scirocco FELIX MORALES

      My PHP works fine following the exact instructions in this article…

  • iperez

    I hope there is someone still maintaining this page…

    I have followed all the steps in installing php but i get a

    Page cannot be displayed

     

    HTTP 403.1 Forbidden: Execute Access Forbidden
    Internet Information Services

     

    I have no idea why i am getting this…

     

    can anyone help

     

    Ilan

     

    • vinod

      i had the same problem

      when i access phpinfo()

      it says

      HTTP 401.3 – Access denied by ACL on resource
      Internet Information Services

       

      can you help to solve this

      i has followed all the steps described above

      • Jorge

        I had the same issue

        HTTP 401.3 – Access denied by ACL on resource
        Servicios de Internet Information Server

        but I create a new virtual folder on my IIS: “otro1/1.php”…

        And now it’s working!!!

        good luck

  • Matt

    Thank you so much – as a beginner I am not too savvy with all this, and I must have read a dozen articles on how to install PHP on IIS.

    THIS IS THE ONLY ONE THAT WORKS – HURRAH

  • Grumpy Jim

    This worked perfectly, first time. I’m a long time ASP designer/developer but need to learn some PHP and having this step work so well is a big help. Thanks for the information.

  • Harish

    Thanks for the installation and configuration info.

    Rgds,

     

  • haden9

    Hello there great article, though one problem I was having was that the php.ini file would not load so I went ahead and added an extra variable to the system variables which was a variable "PHPRC", and its value as "C:\PHP". Thx!

  • Rajendra

    Hello sir,

    your article is great but i have a problem while running php files on IIS.

    Actually the problem is that when i try to run the php page in my internet explorar, instead of running the page my IE shows the code that is written in that php file.

     

    Please help me..

     

    Thanks in advance.

  • http://www.keycomputingsolutions.com Key Computing Solutions

    I tried the MSI installer and it bombed, but when I followed the instructions for a Manual Install it worked right out the gate!

    Thanks Chris!

    Key Computing Solutions

  • Guest

    HTTP 500 Internal server error -It’s shows. How can i do??
    It’s not working..!!!!!

    • Guest

      This page gave me a fix for the http 500 error I was getting: http://support.microsoft.com/?id=311766

  • JNK

    It worked for me for first time itself. I was searching for lot other option over net, couldnt found solution. Now its working great.

  • Guest

    I open the page, and get nothing, just a blank screen, I do a ‘view source’ and I see the phpinfo() directive but its not spitting anything out at me…but no error either….wierd.

  • Chris

    You rock dude

  • Ali

    Hi Chris

    After having endless hassles with the MSI installer from the php site I came across your article.

    Followed your instructions and it worked the first time!

    thanks once again for the precise article!

    Cheers!
    Ali

  • http://www.develop4u.com Guest

    Hi. Thank you for the instructions to set up PHP in IIS. The notes helped guide me however you left out several steps in the process.

    Below are a revised set of your notes. Thanks again for the original:

    Installing PHP on IIS 5.1 (Windows XP Pro)
    By Chris Alexander – Mon, 06/19/2006 – 12:24
    Before we begin any installation steps, the first thing we will need to do is download the PHP zip file from PHP.net
    (www.php.net/downloads.php). The version available at the time of this publishing is 5.1.4.

    Prerequisite: IIS (web server) installed. Click here for tutorial.
    The first step: Extract all of the files from the downloaded zip file into C:\PHP (create the folder if it doesn’t already exist).

    You may choose a different location, although it is not recommended. The path must NOT have spaces, for example, you cannot use C:\Program Files\PHP. Some web servers may not be able to handle the path name and will fault.

    PHP 5 includes a CGI executable, a CLI executable as well as the server modules. The DLLs needed for these executables can be found in the root of the PHP folder (C:\PHP).

    Note: php5ts.dll needs to be available to the web server. To do this, you have 3 options:

    1. Copy php5ts.dll to the web server’s directory (C:\inetpub\wwwroot).

    2. Copy php5ts.dll to the Windows system directory (C:\windows\system32).

    3. Add the PHP directory path to the environment variables PATH. We will go with option 3, because we would like to keep all of our PHP install files in the same location, for easier cleanup later, if needed. Let’s proceed…

    Instructions on how to put C:\php in env variables PATH.

    1. We want to open System Properties. There are two ways to get to System Properties. Either way will work.

    Option 1. Right-Click on My computer and choose “properties”.
    Option 2. Go to Control Panel, and select “System”.

    2. Select the Advanced tab.

    3. In the Advanced tab, click the “Environment Variables” button.
    There are two sections in the Environment Variables window, User Variable and System Variables. We will be using System Variables.

    4. In System Variables, scroll down in System Variables until you find the variable PATH.

    5. Highlight that line and the select Edit below the System Variables window.

    We will only be adding to the Variable Value. BE CAREFUL HERE. You do not want to delete anything on this line.

    5. Find the end of the line and add a semi-colon ( ; ) if there is not one already. After the semi-colon, type: C:\PHP and then hit OK.

    6. Now click OK on the Environment Variables window.

    7. Finally click OK on the System Properties window and we are done with this part.

    8. Restart the computer to make the Environment Variables changes come into play. We cannot simply log off and log on, you must restart.

    The next step is to set up a config file for PHP, php.ini.
    In C:\PHP you will find two files named php.ini-dist and php.ini-recommended. We will use php.ini-recommended for this install, and all you need to do is rename it from php.ini-recommended to php.ini.

    1. Navigate to In C:\PHP.
    2. Find the file php.ini-recommended and rename it to php.ini.
    3. Open the file php.ini in Notepad.
    4. Do a word search for: doc_root =
    5. Append to it so that it reads as: doc_root = C:\inetpub\wwwroot
    6. Do a word search for: cgi.force_redirect
    7. Rewrite it as cgi.force_redirect = 0

    NOTE: be sure to delete the semi-colon that precedes it on the line will be commented out.

    Now PHP is installed, lets move on to preparing our IIS to use PHP.

    Configure IIS to use PHP.

    1. Open IIS

    2. Under Home Directory: Set “Execute Permissions” to “Scripts Only”

    3. Click on configuration.
    a. Click Add
    b. Set “executable” to C:\PHP\php5isapi.dll
    c. Set “extension” to .php (don’t forget to include the . )
    d. Click OK
    e. Click Apply, then OK. Under ISAPI Filters
    a. Click “Add”
    b. Set Filter Name to PHP
    c. Set Executable to C:\PHP\php5isapi.dll
    d. Click OK.
    e. Click Apply, then OK.

    3. click Documents add

    • Ruju

      Hi friend!!

      I was trying to install PHP on my system and somehow not able to do so. After following all the steps suggested in above article, PHP has been successfully installed on my system…

      Thank you so much…!!

    • saami

      thanks for your guide

  • Sara

    Please help, how can i solve this issue
    i really need the PHP to be installed ASAP !!

    thanks

  • Kishore Kumar BV

    Plz Help me To COnfigure IIS for Installing PHP Application

    I cant able to Find the IIS Path ..

    Plz Help me ,

    Thanx In advance.

  • tanmai

    Hello sir,

    your article is great but i have a problem while running php files on IIS.

    Actually the problem is that when i try to run the php page in my internet explorar, instead of running the page my IE shows the code that is written in that php file.

  • http://dayafreeoda.com Dayanand

    I do step by step process as given above and i run my php files.

    thanks
    daya

  • Naran

    Thanks a lot…………..it is working properly

  • Guest

    This was a big help!

  • sudath

    Nice article, it was worked for me at oneshot..
    thanks.

  • Angelo

    It worked the first time. I just needed to follow the instructions. For those having problems probably a little picture of each screen will be more helpful but as it is it worked for me.
    THANKS

  • Guest

    A complete instruction to keep you going with PHP!
    THANKS!!!!

  • Guest

    You can mention to make sure that the automatic installed defaults installation under C:\Program Files\PHP\ it took me 2 hours to figure that it wont work.

    It should be under C:\PHP\

    Thanks for article!

  • Sudha Kankipati

    Thanks for this posting.

  • Hal

    excellent tutorial, man – I am having to learn PHP for a client and i was pulling my hair out trying to get installed. Thanks!!!

  • ilhan

    thank u very very much. worked perfect.

  • Guest

    Thanks Chris! Followed your instructions and got PHP running on IIS in no time. You’re a life saver for a beginner like me… More power to you!

  • Guest

    It is really helped me to install PHP on iis5.1.

    Thanka a lot

  • http://trutheskrimagroup.110mb.com/ malcolmk

    Brilliant help to me in setting up php on my xp machine, now I can try out my website stuff and tweek it before uploading. I have just started learning php and browsing the web for examples, hints etc It seems that frameworks are a good way to keep good clean code , reuse code and access other tried and tested code modules for inclusion in my own project. I downloaded Fatfree recommended as lightweight, good for beginners and easy to install.
    There is no way I can follow what is supposed to be getting started instructions and although Fatfree works with IIS there is no support for it.
    How do you install a php framework on IIS, what exactly does it do and is it worth having?
    hope you can give me some pointers on this.

  • Guest

    Sure, phpinfo.php now works on my server, but nothing else!

  • Guest

    Really nice and useful

    Gaurang

  • Guest

    Hey Chris. Thanks a lot. Dude you’re a LIFE SAVER! go well. Cheers

  • Alex

    I Get This all the time: -2147467259 (0×80004005)

  • Guest

    Just so you know, php5isapi.dll doesn’t exist in PHP 5.3

  • Chandra

    cool…. It worked for me… i used 5.1.4 version only…. awesome!!!!

  • vijay

    thanx a lot for this article…….it was very helpful

  • Anuja

    This post really helped a lot :) After going through so many others, this is the one which gave such simple and to the point steps.
    Thanks so much :)

  • http://none David Morris

    What do you do if when you run phpinfo.php you get the following message:

    “The specified procedure could not be found.”

    I don’t really expect you to be able to answer to this. I’ve been trashing around the forums for several days trying figure out why I can’t run PHP on either IIS or Apache. It was working, but somewhere along the line, when I wasn’t looking, I screwed up my system’s configuration.

    My point is that I’ve looked through several installation and configuration tutorials of the last few days and they all assume the test went well. Not just PHP. I had some trouble getting SQL Server up and running also, and those install/config tuts all assumed everything worked.

    It would be nice if the tutorials would point out some resources to look at if things didn’t go as planned.

    Thanks

    David Morris

    If anyone has any ideas though I’d love to hear them.

  • shishir

    Awesome!! Thanks

  • Join for Access to Our Exclusive Web Tools
  • Sidebar Top
  • Sidebar Middle
  • Sign Up For The Free Newsletter
  • Sidebar Bottom