Install PHP on Windows Server 2012
This article details installing, testing, and configuring PHP on the Windows Server 2012. The article uses the Microsoft Web Platform Installer (Web PI) method of installation. It does not cover the use case of installing PHP from source.
Successfully installing PHP on a Windows Server 2012 requires a prior installation of the IIS framework.
Installing PHP with Web PI
Open the Web PI application from the following location on your filesystem.
C:\Program Files\Microsoft\Web Platform Installer\WebPlatformInstaller.exe
Note: If the Web PI application is not currently installed it can be downloaded via the following link: Web PI
Search for PHP.
Select Add next to the version of PHP you wish to install and click Install.
Note: At the time of writing this is 5.3.19 and 5.4.9
- When prompted to Accept the License terms, review and click I Accept.
Click Finish once the installation is finalized. The PHP runtime environment will be stored on your local file system at the following location:
C:\Program Files (x86)\PHP\%version
Once you have successfully installed PHP you can test its functionality with a few simple steps.
Create a file using a texteditor and insert the following code snippit.
<?php phpinfo(); ?>
This code, when run, 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 directory is C:\inetpub\wwwroot
Open a Web browser and go to the following URL:
With PHP successfully installed a screen will be presented detailing the PHP configuration.
Note: This information can harmful in the wrong hands so please delete or move the info.php file once the installation is successfully tested.
Configuration parameters for PHP are stored in the php.ini file, which resides in the root of the local installation.
- Open File Explorer and path to the PHP configuration (php.ini) file.
Note: The currently loaded configuration file can be found by leveraging the phpinfo(); script in the Testing PHPsection
- Open the file with text editor and perform any necessary modifications.
Note: Explaining the php directives that can be modified is beyond the scope of this article. Those seeking additional assistance should consult the official PHP Manual.
Save the file once you have completed modifications.
Next, restart the IIS service to load any configuration changes. To do so, open the Server Manager from the task bar.
From the Tools menu select Internet Information Services (IIS) Manager. Select the server on the right hand screen and click Restart in the Manage Server section.
Setting the Default Document
To ensure php content is served as the first option the default document setting within the IIS Manager needs to be modified. This section will detail how to modify the Default Document setting within the IIS Manager to perform just this.
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 will now serve index.php files from the wwwroot folder before all other document types.
Continue the conversation in the Rackspace Community.
©2016 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License