Tek Eye Logo

Tek Eye

Install PHP on Windows with Web Platform Installer

PHP: Hypertext Preprocessor, or simply PHP, is a web server scripting language for programming web based applications that are accessed via web browsers. In other words PHP is a computer programming language for the web. PHP can be installed and run on a Windows based PC. Running PHP on Windows is a useful way of testing PHP apps locally before deploying them to a web server. How do you install PHP on Windows? Sometimes PHP comes with development software, however, this article shows you probably the quickest way to install PHP on a Windows computer. PHP can be installed on Windows using Microsoft's Web Platform Installer, a.k.a. WebPI.

PHP Logo

Start with the WebPI App

Microsoft WebPI is the easiest way to install common web technologies onto a Windows PC. Start by going to the Microsoft Web Platform Installer home page. At the bottom of the WebPI install page, under Download WebPI are options for 64-bit Windows (x64), and 32-bit Windows (x86). Choose the download version correct for your Windows.

(To check which version of Windows you have run the System Information app. Type system in the search box and run System Information. Look at the System Type entry to see if it is a x64 or x32 system.)

Run the installation for the Web Platform Installer. If not logged in as a Computer Admin then the administrator password will be required. Once installed type Web Platform in the Windows search box and select Microsoft Web Platform Installer. To run WebPI an administrator account is required. For a standard user use the context menu (normally right-click) and select Run as administrator, entering the correct admin password.

Selecting WebPI

Install PHP on Windows with WebPI

PHP installs are listed in Frameworks in WebPI.

PHP installs in WebPI

Alternatively use search in WebPI to find the PHP packages:

Install PHP in WebPI

For testing PHP on the local Windows machine a webserver is required. Internet Information Services (IIS) is the default Windows webserver. You can set up IIS manually, but if IIS is not already installed, use WebPI to install IIS at the same time as installing PHP.

Install IIS with WebPI

The installer will add other required packages as necessary. Click the Install button and accept the licenses.

Accept WebPI Conditions

WebPI will show a list of all the packages installed.

Installed WebPI Packages

On newer versions of Windows there may be an error message saying that PHP Manager for IIS failed to install. This is a known issue and is only a problem if testing multiple versions of PHP. PHP Manager offers an easy way to switch between different PHP versions. There is a workaround available, however, if using a single version of PHP then PHP Manager is not required.

The installed PHP is now ready to use. Confirm it is working by creating a PHP test page. To see how to set up a website in IIS read everything after section How to Host a Website in IIS in Windows in the article Web Server on Windows with IIS. Use Windows Notepad to create a PHP test file, e.g. called php-test.php. Add the following to the file and save it into the website.


Then browse to it, if everything is installed correctly then PHP info will be shown (otherwise check the IIS configuration, covered in next section):

Testing PHP on IIS

Configure IIS Express for PHP Web Pages

If the PHP test file is not working then check the PHP configuration in IIS. For example 32-bit IIS Express will be installed in:

C:\Program Files (x86)\IIS Express

And an appropriate PHP will be installed in a sub-directory by WebMatrix:

C:\Program Files (x86)\IIS Express\PHP\v5.6

Likewise, for 64-bit IIS Express the install location is usually:

C:\Program Files\IIS Express

And an appropriate PHP:

C:\Program Files\IIS Express\PHP\v7.3

The configuration files for IIS Express are in the IISExpress\config directory in the logged on users Documents folder. The configuration file applicationhost.config can be checked for the correct setup for PHP. The file applicationhost.config can be edited in any text editor, such as Windows Notepad or Notepad++. A default PHP script for a website can be added to the <defaultDocument> section, for example, here is index.php added to the end of the section.

<defaultDocument enabled="true">
        <add value="Default.htm" />
        <add value="Default.asp" />
        <add value="index.htm" />
        <add value="index.html" />
        <add value="iisstart.htm" />
        <add value="default.aspx" />
        <add value="index.php" />

Next, if the <fastCgi> section is empty add the correct settings for the installed PHP. This example is for 64-bit PHP version 7.3:

    <application fullPath="C:\Program Files\IIS Express\PHP\v7.3\php-cgi.exe" monitorChangesTo="php.ini"
            activityTimeout="600" requestTimeout="600" instanceMaxRequests="10000">
            <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
            <environmentVariable name="PHPRC" value="C:\Program Files\IIS Express\PHP\v7.3" />

The next step is the <handlers> configuration:

<handlers accessPolicy="Read, Script">
    <add name="PHP73_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule"
        scriptProcessor="C:\Program Files\IIS Express\PHP\v7.3\php-cgi.exe" resourceType="Either" />

Finally, a <location> section for a website, before the closing </configuration> tag, references the correct PHP handler. For example for the website named EmptySite (which would mimic the website's name in the <site> section):

    <location path="EmptySite">
                <remove name="PHP73_via_FastCGI" />
                <add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule"
                    scriptProcessor="C:\Program Files\IIS Express\PHP\v7.3\php-cgi.exe" resourceType="Either" />

A correctly configured applicationhost.config file should allow the PHP test file to display correctly.

See Also

Author:  Published:  

ShareSubmit to TwitterSubmit to FacebookSubmit to LinkedInSubmit to redditPrint Page

Do you have a question or comment about this article?

(Alternatively, use the email address at the bottom of the web page.)

 This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.

Articles on:

Android Programming and Android Practice Projects, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS, C# Programming, Using Windows for Programming

Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples

Tek Eye Published Projects