Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling PHP on IIS Express with Visual Studio (sans WebMatrix)

I am working on this web application which is mostly .NET, but a part is written in PHP. In my development environment, IIS Express is my web server of choice, so I would prefer to get PHP and .NET work together in this environment.

First naive attempt: Just throw the PHP scripts into the web site, and load them in a browser. The result is an HTTP Error 404.21 - Not Found with the following suggestions:

  • Install PHP and configure handlers correctly.
  • Install and enable PHP for this web site.
  • If you are using WebMatrix, follow these steps to enable PHP:
    • Open the web site in WebMatrix.
    • Select the Site workspace and click on Settings.
    • Check the "Enable PHP" checkbox to install and enable PHP.

Not using WebMatrix, this does nothing to help me. I then proceed to do a deep trawl of anything related to IIS Express and PHP on Google. From what I read, it should be doable, but everything I find about the subject seems to assume that my IDE is WebMatrix. It isn't.

Does anyone know if it is possible to install on IIS Express and configure it to work with a Visual Studio based web site, without having to install WebMatrix? If yes, how?

like image 968
Jørn Schou-Rode Avatar asked May 23 '11 15:05

Jørn Schou-Rode


2 Answers

IIS Express supports PHP without Web matrix. You can install just IIS Express alone and make it work with Visual Studio. For this you need Visual Studio 2010 SP1.

  1. Download IIS Express from this link: Internet Information Services (IIS) 7.5 Express

  2. In Visual Studio configure your WebSite/WebApplication project to use IIS Express. Take a look at this thread How do I configure a website project to use IIS Express?

  3. 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. See this link for details.

If everything is installed in the default places for US English versions of Windows the commands will be:

"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/fastCGI /+[fullPath='"C:\Program Files (x86)\PHP\php-cgi.exe"']
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='"C:\Program Files (x86)\PHP\php-cgi.exe"',resourceType='Unspecified']

Note that if there are spaces in the full path of php-cgi.exe, you MUST enclose the path in single and double quotes as in the example above.

Finally, if you don't have VS 2010 SP1, probably you should take a look at this post: Debug Your .NET Web Project With IIS Express

like image 96
vikomall Avatar answered Oct 04 '22 21:10

vikomall


Another option is to use Web Platform Installer.

  • open Web Platform installer (can be downloaded from http://go.microsoft.com/fwlink/?LinkId=255386)

  • search for PHP for IIS Express

  • click Install

Web Platform Installer will install PHP and configure IIS Express for you.

like image 37
Lukas Kabrt Avatar answered Oct 04 '22 19:10

Lukas Kabrt