Using Windows 7 to host PHP applications in 5 easy steps!

A few people have asked me recently whether it’s possible to setup Windows 7 as a PHP server (for development purposes).  The answer is absolutely yes, and it’s a breeze to setup.  Follow these five simple steps to get PHP up and running in minutes:

1.  In the Programs and Features control panel, click on the Turn Windows features on or off link:


2.  In the list of Windows Features, expand Internet Information Services, World Wide Web Services, and the Application Deployment Features.  If it’s not already, select the CGI checkbox and click OK.  (The most reliable way of hosting PHP applications on Windows 7 is to use the built in FastCGI interface for IIS – checking this box installs it together with any pre-requisites.)


3.  Download the non-thread-safe (NTS) version of PHP from  The current version (as of time of writing is 5.2.9).  (The thread safe (TS) version will also work, but generally NTS is faster, and thread safety is not an issue under FastCGI).  Expand the zip to an installation directory of your choice – e.g. c:devphp

4.  Copy the php.ini-recommended file to php.ini in the PHP directory.  Edit the php.ini file and add correctly configure extension_dir, pointing to the PHP extensions directory (normally the .ext folder of the PHP installation – e.g c:devphpext).  You can also configure other php.ini options and modules here if required.

5.  Run Internet Information Services Manager by typing inetmgr in the Start menu.  You can either set the global settings of the server, or (recommended) add a new web site to run the PHP applications.  Once you’ve done this, double click on the Handler Mappings for the site and add a new module mapping with the following settings:


Request path should be set to *.php.  Module should be FastCgiModule.  Executable should be {php_install_dir}php-cgi.exe.  Name can be anything – I use “PHP via Fast CGI”.

That’s it! Simply start/restart IIS and you are ready to go.  The easiest way to test that everything is working is to create a simple info.php file with a single line:

<?php phpinfo(); ?>

When you access this page from a browser (e.g. http://localhost:8081/info.php), you should see the PHP info screen:


Validate that the server API is using CGI/FastCGI and that the loaded configuration file is the one in your installation directory.

47 thoughts on “Using Windows 7 to host PHP applications in 5 easy steps!

  1. http://

    I have done everything that you have told and i am able to load info.php, but i am not able to run the php files from my project. i get the following error, how do i solve it “PHP Fatal error: Call to undefined function mysql_connect() in C:inetpubwwwrootaaaaaaindex.php on line 6″

    on line 6 i have the myswl connect statement and the code is fine. i have no problems with it. Please help me !!!

  2. smguest

    @Bill – it should be able to run on Professional and Ultimate. The dependency is IIS – which is included in these two.

  3. http://

    blem occurs because the FastCGI module keeps child FastCGI processes in job objects. This design makes sure that all the child FastCGI processes are terminated when a worker process ends. However, job objects cannot be nested in Windows. Therefore, if the application that is using HWC is part of a job object, the FastCGI module functionality will not work when you try to run the FastCGI module inside the application.

  4. klonder

    Nussss!!! Valeu cara! Estava tentando instalar o PHP há 3 dias e nada! Já tinha lido vários artigos e nenhum funcionou!

    Mas agora, após seguir suas instruções, o PHP está rodando e bem aqui no meu pc!


  5. Jo

    I can’t get info.php working but I can run the php files copied from our website.

    Also I can’t run the php files via firefox but I can via IE8 even though I’ve left it at allow anonymous access. Is there something I’ve missed that will allow firefox access?

  6. Tavus

    recently i moved from Windows XP to Windows 7 Ultimate. i have been using php over IIS in Windows XP for over a year without any problem. i’m using Rapid PHP 2008 for editing my php files. i preview my php files either by typing its URL as => http://localhost/main.php where main.php is the file name, or preview through RapidPHP which does the same thing. these are all ok with Windows XP.
    but in Windows 7 Ultimate if i type the same url = http://localhost/main.php i get error HTTP 500. no page is displayed.
    in RapidPHP the Local Web server root directory is => C:inetpubwwwroot and
    Local Web server URL is => http://localhost/ this is how its mapped and working in Windows XP. even if i dont use Rapid PHP 2008 to preview, generally i should be able to type the URL and file name like this => http://localhost/XYZ.php and preview the result. i have set PHP in IIS and have made index.php as default in IIS. i have created a file in wwwroot directory named index.php which contains this and when i run this URL http://localhost/index.php the page displays PHP information correctly.
    but some how Windows 7 and IIS are not getting connected correctly if i want to preview my other files in wwwroot directory.
    Please could you help me. appreciate all your help.with best regards

  7. Michel A.

    Hi Simon,
    Thanks for sharing those informations.
    I have only one question : Would it work for Windows-7 64 bits ?
    Thanks in advance for your answer…
    Have a great day!

  8. Brian

    Hi Simon,
    Thanks for the great article.
    I’m a complete nube and do not know what to put for any of the settings when adding a site.
    Could you possibly give me a quick run through.
    Thanks again,

  9. Panel

    to use inetmgr (Internet Information Services Manager) you allso have to install ‘web managment tools’ in ‘Turn Windows features on or off’

  10. Karl

    Windows 7 Ultimate 64-bit

    When I followed the steps for registering the handle, PHP did not work and it even broke IIS ability to server up a plain HTML page. When I remove the handle mapping, IIS will server HTML again.

    Does anyone have any ideas what went wrong?

    (As someone else suggested, I tried the IIS v7 PHP Manager located here:

    And one click to install the manager and one to configure PHP running on IIS and I was done. Everything worked great.)

  11. Sean

    Could I ask after setting up the localhost, excellent tutorial, using dreamweaver what is the server folder after this installation?

    Many thanks

  12. Luis

    All worked ok for except I had to specify timezone.
    In your php.ini set timezone variable like “Europe/Lisbon” or “UTC”.

    The error I got was “You are *required* to use the date.timezone setting or the date_default_timezone_set() function” when opening info.php

  13. Muhammad Ali

    I am using Window 7,
    PHP 5.3 non thread
    IIS 7
    and have done all above setting to execute PHP on IIS7 and my timezone in PHP.ini is Asia/Karachi

    but have this problem and lost so much time in searching to avoid this error

    PHP Warning: phpinfo(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Karachi’ for ’5.0/no DST’ instead in C:inetpubwwwrootinfo.php on line 1

  14. Fassil

    I am using windows 7 64 bit
    Wamp server with php v 5.3.4
    Mysql v 5.1.53
    Apach v 2.2

    Anyways i spent too much time searching for errors.When i run the code all the codes on the editor are displayed on the browzer.But the code work perfectly on windows xp.

  15. GBF

    Excellent, great instructions. The msi executable on Windows7 took care of the php.ini and handler mappings automatically. Excellent post

  16. kavita

    how and where i copy php.ini recommanded file to php.ini…..i am not getting this text in your instraction

  17. vishal

    Hi….. guys , in my laptop i tried to install php as you mentioned above . when i entered in Application Development Features, I have only .NET extensibility. Any one can tell what to do ? plz

  18. Gerry

    Clear instructions and performed all the tasks but it does not appear that PHP is being accessed by either FireFox or IE-8.
    1. Installed most current Apache24 for Win-7, turned it on, and verified that it is running
    2. In Windows Features turned on CGI in Application Development Features
    3. Installed PHP and updated the php.ini from php.ini-development – made the one change to extension_dir = “ext”
    4. Installed IIS, set Fast CGI to C:phpphp-cgi.exe, started IIS Manage service.

    Checked all of the above twice.

    Any & all suggestions will be gratefully accepted.

  19. Pingback: Twitter API: Using OAuth to access Twitter | Wickedly Smart

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>