How to Install WordPress on Windows Nano Server 2016

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

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

In my case, I’ve Installed MySQL on the same box as my WordPress.

I’ve to say that In order to get this working you will have to know how to use Nano Server.

Before you start,  The prerequisites are a must, You will need a running Nano Server with IIS, FW Disabled,  know how to copy files, PowerShell Remote and Nano Server Package provider.

To make the job easier I’ve listed all the required articles below to overcome the prereq:

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

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

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

Download vcruntime140.dll  (available on any machine which has Visual Studio Installed)

Copy Vcruntime140.dll to c:\windows\system32

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 ( make sure you’ve Installed IIS before this step).

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:

<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 PowerShell ISE,  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

Next, Download WordPress

https://wordpress.org/download/

Extract and copy to the Nano Server C:\Wordpress

Next, Restart IIS Service

Restart-Service w3svc

After restart, I’ll use my browser to start the Installation process

http://192.168.0.104/wordpress/wp-admin/install.php

Optional step

Install WinCasche to optimize PHP on IIS

Download the file from the link below:

https://sourceforge.net/projects/wincache/files/development/wincache-2.0.0.2-dev-7.0-nts-vc14-x64.exe/download

Copy php_wincache.dll to the Nano Server c:\php\ext

Edit PHP.INI with the line below

extension=php_wincache.dll

To verify that the Installation was run the line below from the C:\PHP folder and make sure there are no errors

.\php.exe --ini

Leave a Reply