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 http://www.php.net/downloads.php. 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.
Excelente, funciona muy bien !!!
Thank you, that was helpful.
Great!
What version of Windows7 is required to run the php development environment?
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 !!!
Siva – do you have the correct DLLs for MySQL loaded in your php.ini file?
@Bill – it should be able to run on Professional and Ultimate. The dependency is IIS – which is included in these two.
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.
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!
Obrigado!!!
Gr8,
thanks for this helpfull topic
Not Working For me. Unable to load info.php Please help
Brillant guide – thx.
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?
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
Fardin
what’s the work of wamp?cant we run php by that only without bothering for the iis and all?
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!
Michel
Hi Michel – yes, I’ve found this works fine on 64bit version of Windows 7
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,
Brian
Now there is a IIS add-on which makes setting up and management of PHP on IIS 7 much easier:
http://phpmanager.codeplex.com/
Here is another solution: http://php.iis.net/
to use inetmgr (Internet Information Services Manager) you allso have to install ‘web managment tools’ in ‘Turn Windows features on or off’
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:
http://phpmanager.codeplex.com/
And one click to install the manager and one to configure PHP running on IIS and I was done. Everything worked great.)
Could I ask after setting up the localhost, excellent tutorial, using dreamweaver what is the server folder after this installation?
Many thanks
I do not know what to install the installer.
Translated several articles on IIS on Russian and placed them on his blog Ginom Home.
I can’t find some of the files it says to edit in the php file.
Just download and install PHP for Windows from here:
http://www.microsoft.com/web/platform/phponwindows.aspx
Hi,
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
Very helpfull and fast tuning PHP.
thanx
End of frustration thank you
Helloo
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
Thanks for this wonderful sharing. I have also visited a tutorial which provides more depth of information for installing php on windows 7 with IIS 7 via FastCGI
http://nice-tutorials.blogspot.com/2011/07/installing-php-on-windows-7-with-iis-7.html
Keep up the good work
THANKS!
HI
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.
This is a dumb question but where’s the file: php.ini-recommended that you mention in step 4?
Thank you! With such clear guidance and instructions, I managed to access the page!
inetmgr how can i open by typing inetmgr in the Start menu i do not access
The instructions are now out of date.
Install available from Microsoft http://php.iis.net/
Excellent, great instructions. The msi executable on Windows7 took care of the php.ini and handler mappings automatically. Excellent post
What php.ini-recommended file are you talking about and whre can i find it
how and where i copy php.ini recommanded file to php.ini…..i am not getting this text in your instraction
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
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:\php\php-cgi.exe, started IIS Manage service.
Checked all of the above twice.
Any & all suggestions will be gratefully accepted.
i am using windows 7 all settings are completely installed but mysql & html problem please help
Pingback: Twitter API: Using OAuth to access Twitter | Wickedly Smart
Nice post .good source of information .This is something which can be very useful to many PHP developers like me.