Internet Information Services (IIS)

Learn how to configure an IIS (Internet Information Services) server.

IIS is built in to Windows. On Windows Server, the IIS role can be added via the Server Manager. The CGI Role Feature needs to be included. On Windows Desktop, IIS has to be added via the Control Panel's Add/Remove Programs.

To install IIS

  1. In Windows, access the Control Panel and click Add or Remove Programs.
  2. In the Add or Remove Programs window, click Add/Remove Windows Components.
  3. Select the Internet Information Services (IIS) check box, click Next, then click Finish.
  4. To learn how to use IIS, you can view the documentation at:
    https://localhost/iishelp/iis/misc/default.asp

Configuring IIS

  1. Right-click the My Computer icon on your server computer desktop, and then click Manage.
  2. In the Computer Management dialog box, open the Services and Applications node.
  3. Click Internet Information Services, and then click Web Sites.
  4. Right-click the Default Web Site node to start it, if it is not started already.
  5. If a secure Internet connection is required, set up Secure Sockets Layer (SSL). For more information, see How to: Set Up Secure Sockets Layer (SSL).

Install PHP for Windows

Access https://windows.php.net/download/, then download Non-Thread Safe (NTS) version of PHP.

Once the download is complete, you can extract it to any folder you want, using tar command line:

mkdir C:\php8_5 tar -xf "php-8.5.1-nts-Win32-vs17-x64.zip" -C "C:\php8_5"

Or using Power Shell

Expand-Archive -LiteralPath ".\php-8.5.1-nts-Win32-vs17-x64.zip" -DestinationPath "C:\php8_5"

Configuring PHP with IIS

In IIS Manager, Install FastCGI module and add a handler mapping for .php to the path to php-cgi.exe (not php.exe)

The APPCMD command line tool can be used to script IIS configuration.

If you already have an older PHP installation and want to update it, you can use the following command:

Clear current PHP handlers

%windir%\system32\inetsrv\appcmd clear config /section:system.webServer/fastCGI

The following command will generate an error message if PHP is not installed (this can be ignored):

%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']

Set up the PHP handler

To make things easier, you can define the following variable (depending on the path where php-cgi.exe is located):

set PHP_PATH=C:\php8_5

Then set up the PHP handler:

%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='%PHP_PATH%\php-cgi.exe'] %windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='%PHP_PATH%\php-cgi.exe',resourceType='Unspecified'] %windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script

Configure FastCGI Variables

%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='%PHP_PATH%\php-cgi.exe'].instanceMaxRequests:10000 %windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_PATH%\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']" %windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_PATH%\php-cgi.exe'].environmentVariables.[name='PHPRC',value='%PHP_PATH%\php.ini']"
Go to homepage
Star us on Github