Creating PHP Websites with WebMatrix

Note: WebMatrix now supports PHP "out of the box". You no loger need to do any manual configuration (as detailed in this post) to get PHP support in WebMatrix. For more information, see

Last week, Scott Guthrie (Corporate VP in Microsoft's Developer Division) announced on his blog the beta release of WebMatrix. His post describes what WebMatrix is and how to get started with it, but he focuses mainly on .NET developers. However, he does hint at PHP support, particularly support for PHP applications that are available in the Web Application Gallery. Ruslan Yakushev followed up with a blog post that delved a bit deeper into PHP support in WebMatrix:  Install PHP Applications with WebMatrix. As I read those posts (and others), I was left wondering about the extent of PHP support in WebMatrix (which is what I'll look at in this post). As it turns out, PHP is fully supported, but it requires a little bit of work up front in this beta release of WebMatrix (a smoother experience for PHP developers is planned for the final release). If you want to work on any of the PHP applications that are available in the Web Application Gallery, the experience is very smooth – just follow Ruslan's blog post. However, if you just want to see how WebMatrix works as a PHP IDE for building your own sites (and you don’t want to install one of the PHP apps in the app gallery), then here’s what to do:

1. Download the Web Platform Installer 3 beta here:

2. Run the Web PI and click Install Microsoft WebMatrix on the Getting Started tab. Or, if you want to also install other programs, select Microsoft WebMatrix Beta on the What’s New tab, then select other programs before proceeding.


3. Launch WebMatrix and click on Site From Template:


4. Select an Empty Site and provide a name for the site (I’m calling my “PHPSite”).


5. In a text editor, open the applicationhost.config file located in your Documents\IISExpress8\config directory. Replace the <fastcgi /> element with the following element:

    <application fullPath="C:\PHP\php-cgi.exe"
            <environmentVariable name="PHP_FCGI_MAX_REQUESTS"
                                 value="10000" />
            <environmentVariable name="PHPRC"
                                 value="C:\PHP" />

Note: the fullpath attribute of the application element should point to the cgi executable of your PHP installation. The value attribute for the PHPRC environment variable should point to the location of your PHP installation.

6. Add the following location element as the last child of the configuration element:

<location path="PHPSite">
              <add name="PHP via FastCGI"
                   path="*.php" verb="*"
                   resourceType="Either" />

Note: The path attribute of the location element should be the name of your site and the value of the scriptProcessor attribute should point to the cgi executable of your PHP installation.

7. Save the applicationhost.config file.

8. Back in WebMatrix, click on Files, then on Add a file to your site:


9. PHP will not be listed in the types of files you can add. Instead, choose an HTML file, but name it with a .php extension:


Now you are ready to write PHP code:


That’s it for now. I’ll continue to use WebMatrix and write more about what I find, but I’m hoping this will get you started with using WebMatrix and PHP so you can chime in with your feedback (which I will make sure makes it to the development team).



Share this on Twitter

Comments (10)

  1. tzBron says:

    Just a comment, tried installing WordPress from the Web App Gallery and it failed. I'm hoping it was just because my virus scanner program prevented something from executing not sure what.

    Your PHP basics here will certainly help look into debugging PHP apps with webmatrix, it's funny how without some very basic documentation, makes things almost impossible to know how the MS gang has this puppy wired up, and what is where.

    Not saying a Beta app should have much documentation, but just saying… hopefully it makes it to production, and does not get killed on the cutting floor, like other MS open source projects have done.

  2. txBron-

    Thanks for the comments. Could you be a bit more specific about what you would like to see in the way of documentation? I tend to think folks want the "how to do X" type of documentation, but it sounds like you want "here's a look under the hood" type of docs. Is that correct?

    When WordPress failed to install, did you get an error message? (BTW, I wrote a post about getting WP running with SQL Server:…/running-wordpress-on-sql-server.aspx …in case you are interested.)


  3. Maurice says:

    After editing the config file I fired up webmatrix and got the following error:


    There was an error while performing this operation.

    Filename: \?C:UsersAdminDocumentsIISExpressconfigapplicationhost.config



    System.Runtime.InteropServices.COMException (0x8007000D): Filename: \?C:UsersAdminDocumentsIISExpressconfigapplicationhost.config


      at Microsoft.Web.Administration.Interop.AppHostAdminManager.GetAdminSection(String bstrSectionName, String bstrSectionPath)

      at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath)

      at Microsoft.Web.Administration.ServerManager.get_SitesSection()

      at Microsoft.Web.Administration.ServerManager.get_Sites()

      at Microsoft.WebMatrix.Client.WPF.SiteSelectorControl.GetSitesInMTA()

    Please help!

  4. Maurice-

    My apologies for not updating this post. I wrote this post when WebMatrix was first released. WebMatrix now supports PHP out of the box…there is no need to do any "under the hood" configuration. At step 9 above, you simply choose a .php file type from the available types.

    I'll add a note at the top of this page to alert other readers.


  5. Elicode says:

    When I started using WebMatrix, I used it to write html, css, javascript until when I started learning php. It has a file format/template for php and I think it works really good.

  6. Jayant Kataria says:

    Thank You Sir

  7. Jaykishan says:

    After creating PHP file in web matrix, when I launch it browser via web matrix, it shows error "HTTP Error 404.3 – Not Found

    The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map".

    I'm using web matrix 3. please do the needful asap.

  8. Benno says:

    Thank you so much for your step by step description.

    After I did the preparations I read in the comments that the preparations are no longer neccessary.

    But in both cases (with and whithout preparation (step 9 replaced)) when I click execute in webmatrix I receive an empty page (no error message!), although I used healthy code from w3schools:

    <!DOCTYPE html>




    echo "My first PHP script!";




    Any idea what I did wrong?

    Thank you for your help 🙂



  9. Kenny Bright says:

    Benno, by default index.html page is display when you click execute.

    to view the result of your work, right click your page and select view in browser

  10. FullyHelp says:

    Great <a href="…/" > php tutorials </a> tips for programming. It can help better for php developers.Thanks for this useful post.

Skip to main content