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?
To enable PHP on IIS Express, install PHP and update applicationhost. config (%userprofile%\documents\iisexpress\config\applicationhost. config). You can use the version of appcmd.exe located in IIS Express installation folder for doing this.
IIS only runs on Windows, but keep in mind that running PHP on IIS is not the same as running PHP on Windows. There are options to run PHP on Windows like XAMPP or WampServer. However, these two options make some additional choices for you. They run Apache as a web server and use MySQL or MariaDB as a database server.
php” file is placed inside the “htdocs” folder. If you want to run it, open any web browser and enter “localhost/demo. php” and press enter. Your program will run.
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
Option-1: (From command line)
Go to IIS Express installation folder (%programfiles%\iis express)
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)
Install WebMatrix (from http://www.microsoft.com/web/webmatrix/)
Start WebMatrix and choose 'Site From Folder' option and select your php file folder and click OK
In the WebMatrix left pan select Settings (bottom of the left pan select 'Site' and on the top of the left pan select 'Settings')
In the settings tab, check the PHP check box, this would install PHP and configure for you.
Click 'Restart' button in WebMatrix to restart IIS Express
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With