Run Apache2.4 on Nano Server
Introduction
The Apache HTTP Server, is one of world's most used and popular web server software. Apache played a key role in the initial growth of the World Wide Web, quickly overtaking NCSA HTTPd as the dominant HTTP server, and has remained most popular since April 1996. In 2009, it became the first web server software to serve more than 100 million websites.
Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. Most commonly used on a Unix-like system (usually Linux), the software is available for a variety of operating systems besides Unix, including Microsoft Windows.
Software Used
- - Client computer Windows 10 x64
- - Download the Windows 2016 ISO from Microsoft Evaluation Software Center
- - Mount ISO image ( for me was mounted as F:\ virtual dvdrom ) , copy the folder NanoServerImageGenerator from it somewhere convenient for your setup, i copied it to C:\ so C:\NanoServerImageGenerator is my working folder
- - You can download Apache2.4 from any of the links here http://httpd.apache.org/docs/2.4/platform/windows.html#down , in this article I'm using the one downloaded from this link https://www.apachehaus.com/cgi-bin/download.plx?dli=TdFeORWRBNTTqd2aiFjWzokVOpkVFVVcPRkVTR2Z
- You will need Microsoft® C Runtime Library ( vcruntime140.dll , FileVersion: 14.00.24210.0) for httpd-2.4.23-x64-vc14 to work (you can check the version by right-clicking on it -> Properties -> Product Version or by using PowerShell , see below )
- - Copy vcruntime140.dll (search for it in C:\Windows\System32 folder, on a x64 Windows ,with Visual C++ 2015 Redistributable installed), and httpd-2.4.23-x64-vc14-r3.zip to C:\NanoServerImageGenerator for convenience . Not sure if other libraries are needed , this worked out for me
Steps
Generate Nano Server VHD
# All of the PowerShell commands are run from an elevated terminal
PS C:\WINDOWS\system32> cd C:\NanoServerImageGenerator
PS C:\NanoServerImageGenerator> Import-Module .\NanoServerImageGenerator.psm1
PS C:\NanoServerImageGenerator> dir
Directory: C:\NanoServerImageGenerator
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/11/2016 6:56 PM en-US
-a---- 3/25/2016 2:52 PM 162349 Convert-WindowsImage.ps1
-a---- 11/5/2016 9:33 AM 10064868 httpd-2.4.23-x64-vc14-r3.zip
-a---- 3/25/2016 2:52 PM 445 NanoServerImageGenerator.psd1
-a---- 3/25/2016 2:52 PM 81920 NanoServerImageGenerator.psm1
-a---- 9/11/2016 6:56 PM 391 NanoServerImageGenerator_d1079600-ad0a-4837-8ed9-ce3d6797f5a2_HelpInfo.xml
-a---- 6/9/2016 10:53 PM 87888 vcruntime140.dll
PS C:\NanoServerImageGenerator> Get-Item .\vcruntime140.dll | fl *
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\NanoServerImageGenerator\vcruntime140.dll
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\NanoServerImageGenerator
PSChildName : vcruntime140.dll
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
Mode : -a----
VersionInfo : File: C:\NanoServerImageGenerator\vcruntime140.dll
InternalName: vcruntime140.dll
OriginalFilename: vcruntime140.dll
FileVersion: 14.00.24210.0 built by: VCTOOLSREL
FileDescription: Microsoft® C Runtime Library
Product: Microsoft® Visual Studio® 2015
ProductVersion: 14.00.24210.0
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: English (United States)
BaseName : vcruntime140
Target : {}
LinkType :
Name : vcruntime140.dll
Length : 87888
DirectoryName : C:\NanoServerImageGenerator
Directory : C:\NanoServerImageGenerator
IsReadOnly : False
Exists : True
FullName : C:\NanoServerImageGenerator\vcruntime140.dll
Extension : .dll
...
PS C:\NanoServerImageGenerator> New-NanoServerImage -DeploymentType Guest -Edition Standard -MediaPath "F:\" -ComputerName nanoserver -AdministratorPassword $(ConvertTo-SecureString -AsPlainText -Force "P@ssword") -CopyFiles .\vcruntime140.dll,.\httpd-2.4.23-x64-vc14-r3.zip -TargetPath .\nano.vhd
PS C:\NanoServerImageGenerator> Set-Item WSMan:\localhost\Client\TrustedHosts -Value *
PS C:\NanoServerImageGenerator> Get-Item WSMan:\localhost\Client\TrustedHosts
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client
Type Name SourceOfValue Value
---- ---- ------------- -----
System.String TrustedHosts *
PS C:\NanoServerImageGenerator> dir
Directory: C:\NanoServerImageGenerator
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/11/2016 6:56 PM en-US
-a---- 3/25/2016 2:52 PM 162349 Convert-WindowsImage.ps1
-a---- 11/5/2016 9:33 AM 10064868 httpd-2.4.23-x64-vc14-r3.zip
-a---- 11/5/2016 11:20 AM 710089216 nano.vhd
-a---- 3/25/2016 2:52 PM 445 NanoServerImageGenerator.psd1
-a---- 3/25/2016 2:52 PM 81920 NanoServerImageGenerator.psm1
-a---- 9/11/2016 6:56 PM 391 NanoServerImageGenerator_d1079600-ad0a-4837-8ed9-ce3d6797f5a2_HelpInfo
.xml
-a---- 6/9/2016 10:53 PM 87888 vcruntime140.dll
Create VM and install Apache
- Create a new Hyper-V VM , attach the nano.vhd when asked about virtual hard disk
- Start the VM , login with Administrator/P@ssword (if you didn't change it), select Networking -> Ethernet , to see your IP address (mine was 192.168.133.224)
PS C:\NanoServerImageGenerator> Enter-PSSession 192.168.133.224 -Credential administrator
[192.168.133.224]: PS C:\Users\Administrator\Documents> cd\
[192.168.133.224]: PS C:\> dir
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 5:20 AM Program Files
d----- 7/16/2016 5:09 AM Program Files (x86)
d-r--- 11/5/2016 2:06 AM Users
d----- 11/5/2016 1:58 AM Windows
-a---- 11/5/2016 12:33 AM 10064868 httpd-2.4.23-x64-vc14-r3.zip
-a---- 6/9/2016 12:53 PM 87888 vcruntime140.dll
[192.168.133.224]: PS C:\> Expand-Archive .\httpd-2.4.23-x64-vc14-r3.zip
[192.168.133.224]: PS C:\> mv .\httpd-2.4.23-x64-vc14-r3\Apache24\ .
[192.168.133.224]: PS C:\> rm .\httpd-2.4.23-x64-vc14-r3\ -Force -Recurse
[192.168.133.224]: PS C:\> cp .\vcruntime140.dll .\Apache24\bin\
[192.168.133.224]: PS C:\> .\Apache24\bin\httpd.exe -k install -n "httpd"
.\Apache24\bin\httpd.exe : Installing the 'httpd' service
+ CategoryInfo : NotSpecified: (Installing the 'httpd' service:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The 'httpd' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
# this is complaining about ServerName warning/error not set globally , you can ignore it
[192.168.133.224]: PS C:\> Get-Service httpd
Status Name DisplayName
------ ---- -----------
Stopped httpd httpd
[192.168.133.224]: PS C:\> Start-Service httpd
[192.168.133.224]: PS C:\> Get-Service httpd
Status Name DisplayName
------ ---- -----------
Running httpd httpd
[192.168.133.224]: PS C:\> New-NetFirewallRule -Name "Allow-Web-Service" -DisplayName "Allow incoming connection on TCP port 80" -Enabled True -Profile Any -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80
Name : Allow-Web-Service
DisplayName : Allow incoming connection on TCP port 80
Description :
DisplayGroup :
Group :
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : The rule was parsed successfully from the store. (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
Test the setup
- Point your browser to http://192.168.133.224 in my case , yours will be different and you should see the Apache webserver index page