Install IIS and PHP on a Windows Server or Desktop
+
Overview
This tutorial provides instructions with a step by step guide on how to setup a web server (IIS) and PHP on Windows and some alternative options. Installing PHP on Windows is relatively quick and simple because Microsoft provides easy to use installers.
Quick Tip
If you only need PHP for local development you can skip the IIS install and jump to installing PHP or see additional links in this section of the page.
Web Platform Installer
Microsoft’s Web Platform Installer (WebPI) can be used to install multiple version of PHP both on regular desktops (Windows 10, etc) for development and on Windows Servers for production.
Alternative Development Environments for PHP with Windows
This tutorial shows how to use a Microsoft supported program for installing PHP, however many alternative options exist for local development. Here are a few:
Additional PHP Install Resources
There are many ways that PHP can be installed. To find out more see additional links or search online.
Connect to the Windows Server
If installing PHP on a Windows Server you will likely use Remote Desktop Connection (RDC) to connect to the server.
Open RDC by searching for “Remote” ou "mstsc" in the start menu; once opened you will see a login screen.
Specifying “.\” before the user name will use the local network of the computer that you are connecting to rather than your domain. This may or may not be needed depending on where and how you are connecting.
You may see a certificate warning when connecting. This is a common warning and it’s typically safe to click [Yes].
Install IIS on Windows Desktop
If you are using a Windows Desktop Computer such as Windows 10 you can install IIS from [Programs and Features] by turning it on as a Windows Feature. Using IIS for PHP development is not required for PHP development because PHP has a built-in Web Server.
Install IIS on Windows Server
This page shows how to install IIS and PHP on a recent version of Windows. If you have a very old server (example Windows 2003 with IIS 6) you can still install PHP however you will want to search for other links online as the steps will be different.
First open [Server Manager] from the Start Menu.
Click [Add roles and features]
You will go through a Wizard. Click the [Next] button.
You can leave the default options until you get to the [Server Roles] selection. Then select [Web Server (IIS)].
For this tutorial we are leaving the default options however you may want to change them based on your needs. Click [Next] and then finish the setup. Once complete IIS will be setup on your server.
Download Microsoft's Web Platform Installer. [https://www.microsoft.com/web/downloads/platform.aspx]
Windows Servers typically block most sites and downloads by default so you may see this warning if using IE. To work-around the issue, change IE Security Settings, download the Web Platform Installer from another browser (a portable version for example) if available, or download from another computer and copy the installer through RDC.
The Web Platform Installer is a simple setup wizard with one screen.
Once installed you’ll see it in the Start Menu.
Search for “php” or a specific version such as “php 7.3”. The Web Platform Installer provides many different versions of PHP and various extensions.
In this example we are going to install PHP 7.3.1 which is the latest version of PHP (at the time this tutorial was created), and we are going to install PHP SQL Server Drivers for IIS. You’ll notice that there is an option for each version of PHP to install for [IIS Express]. IIS Express is used for local development and not the full version of IIS so we do not select it here.
Depending on the speed of your computer and internet the installation may take around a minute to a few minutes.
In this example an error came up during the install however it was for un-used extension that is not needed and the main PHP install worked.
Create and View a PHP Page
The default web root folder when using IIS is [C:\inetpub\wwwroot]. Here a file [phpinfo.php] is added using Notepad. This file will output PHP version, config info, etc.
<?php
phpinfo();
Viewing the page from localhost shows that PHP is installed and correctly working.
The install location may vary for your server however here it is installed at [C:\Program Files\PHP\v7.3]. You can see that the Web Platform Installer sets up needed config options such as the timezone. The extension folder typically includes many addition extensions that are not enabled by default; if you need them view the related files to make sure they exist and then add them to the [ExtensionList] in the [php.ini] file.
Setup the FastSitePHP Starter Site
Download the FastSitePHP Starter Site from https://www.fastsitephp.com/downloads/starter-site or directly from GitHub https://github.com/fastsitephp/starter-site/archive/master.zip
Either link result in the file starter-site-master.zip
being downloaded.
Unzip the file and copy the following folders:
Copy folders:
starter-site-master\app
starter-site-master\app_data
starter-site-master\scripts
Copy under:
C:\inetpub
These three folders will exist outside of the IIS public web root folder wwwroot
.
Run the install script, this takes only a few seconds and installs the FastSitePHP Framework to C:\inetpub\vendor
.
cd C:\inetpub\scripts
php install.php
Copy public files and folders to the web root folder.
Copy from:
starter-site-master\public\
css
img
js
index.php
Web.config
favicon.ico
robots.txt
Copy under:
C:\inetpub\wwwroot
View the site! Congratulations if you have followed all of these steps then you have setup a Windows Server with IIS for production usage.