Install PHP on Windows Server 2012 and Later
This article describes how to install, test, and configure PHP on Microsoft®
Windows Server® 2012 and later. The article uses the Microsoft Web Platform
Installer (WebPI) for installation and does not cover installing PHP from
the source.
Prerequisites
Before installing PHP on Windows Server 2012 and later, you should install
the Internet Information Services (IIS) framework.
You should also install the
Microsoft Windows Cache extension for PHP.
Install PHP with WebPI
-
Open the WebPI from the following location on your
file system:C:\Program Files\Microsoft\Web Platform Installer\WebPlatformInstaller.exe
Note: If the WebPI is not currently installed, you can download
it from WebPI. -
Click the Products tab, click Frameworks, and then scroll down the
PHP choices. -
Select Add next to the version of PHP you want to install and
click Install. -
When prompted to accept the license terms, review them and click I Accept.
-
Click Finish after the installation completes. The PHP runtime
environment is stored on your local file system at the following
location:C:\Program Files (x86)\PHP\%version
Test PHP
After you have successfully installed PHP, you can test its functionality
with the following steps:
-
Create a file by using a text editor and insert the following code
snippit:<?php phpinfo(); ?>
-
When you run this code, it presents detailed information about the
current PHP configuration of the local system. Save the
file as info.php in the IIS root directory.Note: The default IIS root directory is C:\inetpub\wwwroot.
-
Open a web browser and go to the following URL:
https://localhost/info.php
With PHP successfully installed, a screen displays that details the PHP configuration.
Note: This information can be sensitive so be sure to delete
the info.php file after the installation is successfully tested.
Customize PHP
The php.ini file that resides in the root of the local installation stores
the configuration parameters for PHP. To customize PHP, use the following
steps:
-
Open the File Explorer and set the path to the php.ini file.
Note: You can find the currently loaded php.ini file by leveraging the
phpinfo();
script used in the preceding section. -
Open the file with a text editor and perform any necessary modifications.
Note: For more information on PHP directives, see the official
PHP Manual. -
Save the file after you complete your modifications.
-
Next, restart the IIS service to load any configuration changes.
-
Open the Server Manager from the task bar.
-
From the Tools menu, select Internet Information Services(IIS) Manager.
-
Select the server in the right-hand screen and click Restart in the Manage Server section.
Modify the default document settings
To ensure that PHP content is served as the first option, you should modify
the default document setting within the IIS Manager by using the following steps:
-
Open the Server Manager from the task bar.
-
From the Tools menu, click Internet Information Services(IIS) Manager.
-
In the Internet Information Services (IIS) Manager, select the
server homepage. -
Double-click the Default Document option.
-
Select the index.php option and move it to the top of the
list.
IIS now serves index.php files from the wwwroot folder before all other document types.
Updated about 1 year ago