How To Install PHP on Windows Nano Server 2016

In this article, I’ll show you how to Install PHP 7 on Windows Nano Server 2016.

This article continues from the previous two articles I’ve published about how to Install MySQL Database Server and WordPress on Windows Nano Server 2016.

  1. How To Install MySQL Database Server On Windows Nano Server 2016 (April 2017)
  2. How Manage A MySQL Database Server Installed on Windows Nano Sever 2016
  3. How to Install WordPress on Windows Nano Server 2016

Before you start, Make sure you follow the prerequisites using the articles below, You will need a running Nano Server with the Firewall configured, etc.

  1. Install Nano Server
  2. Disable the Firewall on Windows Nano Server
  3. Connect to Nano Server using PowerShell
  4. Install Nano Server package provider
  5. Install IIS
  6. Copy Files to Nano Server

Once you everything configured and Installed, Download PHP for Windows from the link below:

http://windows.php.net/downloads/qa/

Extract the file and Rename the folder to PHP and copy to Nano Server

copy vcruntime140.dll from a machine with Visual Studio Installed

Copy Vcruntime140.dll to c:\windows\system32 on the Nano Server

Next, Verify file IISFCGI.dll exist In:

c:\windows\system32\inetsrv\iisfcgi.dll

Connect, to Nano Server using PowerShell and Enable the IIS-CGI feature using the cmdlets below

Import-module iisadministration
DISM.EXE /enable-feature /online /featureName:IIS-CGI /all

Edit applicationhost.config from the path below:

c:\windows\system32\inetsrv\config\applicationhost.config

Verify the settings Is set to Default.php:

<defaultDocument enabled="true"><files><add value="Default.php">

Add the code below under FastCGI:

<application fullPath="C:\PHP\PHP-CGI.EXE" maxInstances="0" instanceMaxRequests="10000">

<environmentVariables>

<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />

<environmentVariable name="PHPRC" value="C:\PHP" />

</environmentVariables>

</application>

Add the line below under <handlers accessPolicy=”Read, Script”>:

<add name="PHP-iisfcgi" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\PHP\PHP-CGI.EXE" resourceType="Either" requireAccess="Script" />

Run the code below from ISE which connecting to the Nano Server

Reset-IISServerManager -Confirm:$false
Get-IISConfigSection system.webServer/defaultDocument | Get-IISConfigElement -ChildElementName files | Get-IISConfigCollection | New-IISConfigCollectionElement -ConfigAttribute @{"value"="index.php"}

Get-IISConfigSection system.webServer/fastCgi | Get-IISConfigCollection | New-IISConfigCollectionElement -ConfigAttribute @{"fullPath"="C:\PHP\PHP-CGI.EXE";"maxInstances"=0;"instanceMaxRequests"=10000}

Get-IISConfigSection system.webServer/fastCgi | Get-IISConfigCollection | Get-IISConfigCollectionElement -ConfigAttribute @{"fullPath"="C:\PHP\PHP-CGI.EXE"} | Get-IISConfigElement -ChildElementName environmentVariables | Get-IISConfigCollection | New-IISConfigCollectionElement -ConfigAttribute @{"name"="PHP_FCGI_MAX_REQUESTS";"value"="10000"}

Get-IISConfigSection system.webServer/fastCgi | Get-IISConfigCollection | Get-IISConfigCollectionElement -ConfigAttribute @{"fullPath"="C:\PHP\PHP-CGI.EXE"} | Get-IISConfigElement -ChildElementName environmentVariables | Get-IISConfigCollection | New-IISConfigCollectionElement -ConfigAttribute @{"name"="PHPRC";"value"="C:\PHP"}

Get-IISConfigSection system.webServer/handlers | Get-IISConfigCollection | New-IISConfigCollectionElement -ConfigAttribute @{"name"="PHP-iisfcgi";"path"="*.php";"verb"="GET,HEAD,POST";"modules"="FastCgiModule";"scriptProcessor"="C:\PHP\PHP-CGI.EXE";"resourceType"="Either";"requireAccess"="Script"} -AddAt 0

Start, IIS services and verify using a PHP Info file PHP Is running:

Start-Service was
Start-Service w3svc
get-iissite | Start-IISSite

Create a PHP file called PHP.php with the content below:

<?php

phpinfo();

?>

Create a PHP.INI file with the content

[PHP]

extension_dir=c:\php\ext

extension=php_mysqli.dll

done, at this stage PHP Is running and ready to be used.


Posted

in

,

by