Write Review

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

For this article, we’ll make use of the Microsoft’s IIS as the web server on Windows Server 2012 R2 (x64). You need to download the latest version of PHP 7.0.x and ensure that you download the NTS (Non-thread safe) version and the x64 build.

The installation of PHP7 on the serve needs to go through a few different installation and practical step by step tips. Here we go:

  • You need to first download the PHP binaries
  • You’ll download and install the VC14 (Visual C++ 2015) runtime.
  • You’ll also install the CGI module in IIS
  • Finally, you need to configure PHP in IIS

How To Download The PHP Binaries

To download the most recent release of PHP binaries, you can go to thePHP website from this link:

You need to be careful with the version you’ll download, if your serve operates with the 64-bit version of Windows, you’ll commonly select download and look for the x64 NTS (non-thread safe) version of PHP.

As soon as you have finished downloading it, extract all the files to C:PHP. You’ll use this to stockpile PHP binaries and configuration files.

Download and Install The Visual C++ 2015 Runtime

PHP7 has been compiled in Visual Studio 2015 and there is required to be the VC 2015 runtime that come installed on the server. Again, it is significant that you install the version that matches your server’s hardware architecture (x32 or x64). However, you can as well install the two of them to get what you want.

To download the latest VC C++ 2015 runtimes from the Microsoft website, you can go to this link:  https://www.microsoft.com/en-gb/download/details.aspx?id=48145

Install the runtime as illustrated above. After you’ve done that, the good practice is to restart your server. This will enable the alterations you’ve made to take effects.

Install The CGI Module For IIS

To install the CGI module to allow IIS to “talk” to PHP, go to your windows explorer, click on the Administrative Tools section. You’ll find this in the Control Panel. To get there, navigate to your systems’ Control PanelAll Control Panel ItemsAdministrative Tools

As soon as you open the Server Manager tool, you’ll see an Add Roles tab, hit on the tab and make sure that you select the “CGI” is from the dialog box as illustrated in the screenshot below:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

When you have done this select the Next and Continue to install your CGI module. As soon as you get to this step, restart your server. Alternatively, restart your IIS.

Despite the fact that this article was written for Windows Server 2012 R2, if you want to install PHP7 on Windows which are different for the one meant for this article like windows vista and Windows 7, you can see the CGI feature under: Control PanelPrograms and Features. After you have opened Programs and Features tab, navigate to the left side of the page with the tag “TurnWindows Features On or Off “Among the list of services that’ll be displayed go to the Internet Information ServicesWorld Wide Web ServicesApplication Development Features and select the CGI.

How To Install PHP7

After you have installed the requisite runtimes and enabling on your IIS the CGI module, you can now begin to the last part of this exercise. And that is how you can install!

Making use of the Administrative Tools which is located within the Control Panel, you’ll navigate to the Internet Information Services (IIS) Manager app and click on it to open it.

When it is open, go to the left hand menu on the page and click on the server’s name. When this opens navigate to the main menu and tap the Handler Mappings icon as illustrated below:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

You’ll see the present current handler mappings that the server supports. Navigate to the right hand side of the window, there you’ll find a lot of Action links, click on the tab specified Add Module Mapping… as presented in the screenshot below:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

As soon as you see the Add Module Mapping window, input the values as illustrated below:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

Then, navigate to the Request Restrictions tab and don’t mark the Invoke handler except the request is mapped to: and after that choose the File radio button…

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

At this point, click Ok and click again the second time. As soon as you’ve done this, you’ve configured the module mapping.

Despite the fact that it is not compulsory, the best practice is for you to configure a default document to enable the directory level access to pages  to routinely give out to the “index” page. Commonly, when serving PHP sites, the “index.php”  is set up as the default index page…

To configure a fresh index page, choose the server name from the left hand menu and click on the Default Document tab two times as illustrated below:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

Go to the right hand menu of the Default Document panel, check for the option labeled Add and click on it to create a new one. By clicking on the Add link and after that in the pop-up window that appears input index.php. When you are done with this click on Save as the screenshot below illustrates:

How to Install PHP7 on Windows Server 2012 R2 and IIS 8

As soon as you have done this, you’ve done all that is required to integrate a fresh site and you will now be able to incorporate an index.php file into the root of the home directory.

To verify that everything is okay, you can generate a file and name it index.php with the content below:

?php phpinfo(); ?>

When you’ve done that, load the files. This will show you the entire PHP runtime setup and all the extensions that are loaded on to it.

At this stage, the PHP7 you install is enabled in a vanilla form. The implication of this is that, it is currently the only PHP you have installed and that there are no other PHP extensions allowed currently. Same also applies to the timezone and so on. None of these has been configured.

What you need to do now is to copy one PHP configuration templates to the “working” copy and after copying it, modify it and with the use of the Command Prompt run the following command:

copyC:PHPphp.ini-production C:PHPphp.ini

Step 1: Set The Server’s Timezone

The first thing we’ll need to do is to set the server’s timezone. Therefore, locate and uncomment the line and after that set your timezone                as required.

;date.timezone =

If you are in Europe for example, you can select ‘Europe/London’ to represent your timezone. This changes your line into the line below:

date.timezone = Europe/London

Step 2: Set Up The Extension Directory

At this point you are required to configure the extension direction, thus look for it in this step:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"

Step 3: Uncomment The (“;”) Character

At this point, you need to un-comment or take out (“;”) character before the extension_dir = “ext” line for it to turn into:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

Step 4: Uncomment A Few CGI “fixes” For IIS

Lastly, we will uncomment a few CGI “fixes” for IIS. This will enhance security and performance, thus, try and uncomment the lines below and configure them to correspond to the values in the example below:

; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this onby default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off forIIS, infact, you MUST.**
; http://php.net/cgi.force-redirect
cgi.force_redirect = 0
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. Formore information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; http://php.net/cgi.fix-pathinfo
; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
; security tokens of the calling client. This allows IIS to define the
; security context that the request runs under. mod_fastcgi under Apache
; does not currently support this feature (03/17/2002)
; Set to 1 if running under IIS. Default is zero.
; http://php.net/fastcgi.impersonate
fastcgi.impersonate = 1


As soon as you’ve saved the php.ini file, you can restart your app pool(s). Alternatively, just start over IIS to allow the modifications you made to apply. The detail tips here should be able to help you install Php7 without hassle. However, if get stuck along the way, we are here to help you!

Check out these top 3 Windows hosting services:

Was this article helpful?