16

I have Win XP SP3 and have installed IIS7.5 Express and want to run PHP on it.

I am able to run simple HTML code on the server, I am able to start and stop the server by running iisservices.exe, but I am not able to run php scripts on it.

If I have the following PHP file:

<? php 
echo "hello world";
?>
<html>HI</html>

The output is HI but the PHP script doesn't run.

I have followed the steps described in this article to install PHP:

http://learn.iis.net/page.aspx/724/install-and-configure-php/

But can't proceed from step 10 onwards because IIS Express doesn't have an IIS Management Console MMC snap-in.

How do I configure IIS Express to run PHP?

vikomall
  • 17,379
  • 6
  • 49
  • 39
Saurabh
  • 161
  • 1
  • 1
  • 3

3 Answers3

38

Assuming you've carried out steps 1 - 9 in the article you linked to and have your PHP files extracted to c:\php then complete the following steps using a cmd.exe command prompt:

Firstly we need to configure IIS Express and setup a handler for PHP

cd "\Program Files\IIS Express"

appcmd set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\php-cgi.exe',arguments='',maxInstances='4',idleTimeout='300',activityTimeout='30',requestTimeout='90',queueLength='1000',instanceMaxRequests='200',protocol='NamedPipe',flushNamedPipe='False',rapidFailsPerMinute='10']" /commit:apphost

appcmd set config -section:system.webServer/handlers /+"[name='PHP-FastCGI',path='*.php',modules='FastCgiModule',verb='*', scriptProcessor='c:\php\php-cgi.exe']" /commit:apphost

Assuming your PHP website resides in c:\MyPHPWeb we create a site in IIS Express that listens on http://localhost:32701:

appcmd add site /name:"MyPHPApp" /bindings:http/*:32701: /physicalPath:"c:\MyPHPWeb"

Next start the site:

iisexpress.exe /site:MyPHPApp

And finally browse to your PHP page:

http://localhost:32701/test.php
Kev
  • 118,037
  • 53
  • 300
  • 385
  • I wish I could mark this as the answer but it is not my question...best I could do was mark it as useful. It was exactly what I was looking for. Thanks! – Jason Sep 14 '11 at 13:41
  • 1
    I was trying this on my mac book with vmware fusion and I had to stop the shared folder in order for this to work – orellabac Apr 11 '13 at 04:38
  • 2
    For anybody setting this up on Windows(7 for me) and it's saying you don't have permission to start the site, make sure you run command prompt as administrator. – Chris Trudeau Jan 17 '14 at 03:36
  • 1
    I'm running on Win10 Creators Edition and this was exactly the config I needed (other than replacing the `php-cgi.exe` location with `C:\Program Files (x86)\IIS Express\PHP\v7.1\php-cgi.exe`. +1 also on the note to run IISExpress as an Administrator. – Peter Sep 19 '17 at 09:36
4

Option-1: (From command line)

  1. Go to IIS Express installation folder (%programfiles%\iis express)

  2. Run following two commands

appcmd.exe set config /section:system.webServer/fastCGI /+[fullPath=**'c:{php_installation-folder}\php-cgi.exe'**] 

appcmd.exe set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='.php',verb='',modules='FastCgiModule',scriptProcessor='c:{php_installation-folder}\php-cgi.exe',resourceType='Unspecified'] 

Option-2: (Using UI)

  1. Install WebMatrix (from http://www.microsoft.com/web/webmatrix/)

  2. Start WebMatrix and choose 'Site From Folder' option and select your php file folder and click OK

  3. In the WebMatrix left pan select Settings (bottom of the left pan select 'Site' and on the top of the left pan select 'Settings')

  4. In the settings tab, check the PHP check box, this would install PHP and configure for you.

  5. Click 'Restart' button in WebMatrix to restart IIS Express

  6. In WebMatrix left pan bottom select 'Files' and on the top of the left pan (tree view), you should see your php page and now right click on this page node and select 'Launch in Browser'

Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
vikomall
  • 17,379
  • 6
  • 49
  • 39
-4

Download php installer.

It should let you choose what type of server, so choose IIS and then it should work from there.

Naftali
  • 144,921
  • 39
  • 244
  • 303
  • What? im not asking for **any** of your info. I am just telling you how to make your code work... – Naftali Aug 16 '11 at 15:09