With the implementation of Windows Subsystem for Linux, many new scenarios will are available for all IT Admins. One of these is use IIS and Apache in the same box; don’t forget that Apache is already available for Windows but the idea is use the native base (Linux). I had showed how to install and configure Linux on Windows Server RS3, so in this article we will see the configuration of Internet Information Services and Apache on Linux.
Install IIS
To enable IIS, use this script:
Install-WindowsFeature -Name NET-Framework-45-ASPNET
Install-WindowsFeature -Name Web-Server,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Static-Content,Web-Http-Redirect,Web-Health, Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Performance,Web-Stat-Compression,Web-Security,Web-Filtering,Web-Basic-Auth,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext,Web-Net-Ext45,Web-Asp-Net,Web-Asp-Net45,Web-CGI,Web-ISAPI-Ext,Web-ISAPI-Filter
After the procedure, test the result from browser, as showed in figure 1.
Figure 1 – IIS Running
Create Site
Depends by your confidence with PowerShell, but you can work via line or it is also possible upload web files via Explorer – figure 2.
Figure 2 – Remote Folders
Create a new folder and upload contents. Now it’s time to create the new site, with this script:
New-IISSite -Name “Inside Tech Lab” -PhysicalPath “C:\inetpub\wwwroot\InsideTechLab\” -BindingInformation “*:80:www.insideweb.net” -Verbose
The record www.insideweb.net must be present into host file or in your DNS Server. Test the result from browser – figure 3.
Figure 3 – Site Running in IIS
Install Apache
For this article, I will use Ubuntu. If you want to know how to install WSL, check my article here.
To simplify future task, I use tasksel that install the entire LAMP (Linux Apache MySQL PHP) stack.
apt install tasksel
tasksel install lamp-server
Run the command service apache2 status to check if the engine is up, in case use service apache2 start to enable the service.
Configure Firewall
Two web engines in the same machine can survive but is necessary assign a dedicated port to respond and this can be done with a new firewall rule. In this case I want to add a new port (81) and assign all new call to Apache. This cmdlet creates a new exception rule:
New-NetFirewallRule -Name “Custom Apache HTTP 81″ -DisplayName ” Apache 81″ -Protocol TCP -LocalPort 81 -Action Allow
Configure Apache
To allow call from port 81, is necessary reconfigure file /etc/apache2/ports.conf and change the variable Listen from 80 to 81, as showed in figure 4.
Figure 4 – Change Port
Last step is reconfigure the file default web site configuration file. Before, remove the binding with command a2dissite 000-default.conf. now you can run command nano /etc/apache2/sites-available/000-default.conf and change the variable VirtualHost to *:81, as showed in figure 5.
Figure 5 – Change VirtualHost
Run a2ensite 000-default.conf and also service apache2 restart to apply changes. Test the result from browser – figure 6.
Figure 6 – Site Running
Create Site
Linux is not Windows and some steps must be followed. First create a new folder and assign the permission:
mkdir -p /var/www/ insidetechlab
chown -R www-data:www-data /var/www/insidetechlab
Content can be copied via bash or via Windows Explorer (\\10.10.1.62\c$\Linux\Ubuntu\rootfs\var\www).
Duplicate the config file from /etc/apache2/sites-available/000-default.conf with command cp 000-default.conf insidetechlab.conf – edit this file and add these variables:
ServerName www2.insideweb.net
ServerAlias www2.insideweb.net
DocumentRoot /var/www/insidetechlab
Figure 7 – Personalize site.conf
Run a2ensite insidetechlab.conf and also service apache2 restart to apply changes. Test the result from browser – figure 8.
Figure 8 – Site Running in Apache
Conclusions
This is a great way to use one single machine to run different web engine. Some applications requires Apache on Linux to works fine and with Windows Server there will be the possibility to reduce the hardware cost.
S