Although this is not a common software combination, some people might want to leverage the advantages of Windows servers, while still being able to develop and run PHP applications. In this tutorial, we will see how to install IIS Web server and PHP on a Windows Server 2012.
On Windows Server operating systems, IIS Web server is not installed by default. However, it can be easily installed by going to Server Manager > Add Roles and Features. On the first three tabs, just click next. Then, on the tab "Server Roles" find "Web Server (IIS)" in the list, check it and click next. On the next tab ("Features"), mark .NET framework features for installation. Then, continue clicking "Next" until the installation starts. After the installation has been completed, the default IIS page should be visible at: http://localhost/.
On Windows machines, PHP can be installed by using Microsoft Windows Platform Installer, which can be downloaded from here. (if you are new to Windows, you would need to change the Internet Explorer security settings). After running the installer, click on "products", then "frameworks" and select the appropriate PHP version from the list. For the purposes of this tutorial, we will install PHP 5.6.24, but it is also possible to choose some earlier PHP versions or PHP 7.
Once the installation has been completed, let's test whether everything went smoothly. Go to C:\inetpub\wwwroot (this is the Web server's root folder) and create a file named info.php containing the following code:
Save it and open the following URL in the Web browser: http://localhost/info.php. Something like this should show up:
In IIS Web server, various Web site configurations can be managed through the graphical interface. It is a good practice to create each project as a Web site through the interface. To do that, go to Server Manager > Tools > Internet Information Services (IIS) Manager. On the left side, all Web sites will be listed. Right click on "Sites" and then click "Add Website."
PHP settings can be changed by editing the php.ini file, which is located in the folder where PHP is installed (e.g. C:\Program Files (x86)\PHP\v5.6\php.ini). After editing the file, restart IIS in order to apply the new changes.
PHP configuration can also be managed through the graphical interface. Go to Server Manager > Tools > Internet Information Services (IIS) Manager and click on the server name on the left side. In the middle of the screen, double-click "PHP manager". Click on "Manage all settings" to change php.ini values, "Add an extension" to install a new PHP extension or "Enable or disable an extension" to manage extensions that have already been installed.
The Windows Platform Installer, which we have used to install PHP, also provides a setup wizard for many popular PHP applications. Click the "applications" tab, select the desired application and follow the wizard steps. Some of the offered applications are WordPress, Magento, SugarCRM, Joomla, Umbraco, Moodle and others.