1 # Copyright (c) Microsoft Corporation. 2 # Licensed under the MIT License. 3 4 Import-Module $PSScriptRoot/Apache/Apache.psm1 5 6 #list Apache Modules 7 Write-Host -Foreground Blue "Get installed Apache Modules like *proxy* and Sort by name" 8 Get-ApacheModule | Where-Object {$_.ModuleName -like "*proxy*"} | Sort-Object ModuleName | Out-Host 9 10 #Graceful restart of Apache 11 Write-Host -Foreground Blue "Restart Apache Server gracefully" 12 Restart-ApacheHTTPServer -Graceful | Out-Host 13 14 #Enumerate current virtual hosts (web sites) 15 Write-Host -Foreground Blue "Enumerate configured Apache Virtual Hosts" 16 Get-ApacheVHost |Out-Host 17 18 #Add a new virtual host 19 Write-Host -Foreground Yellow "Create a new Apache Virtual Host" 20 New-ApacheVHost -ServerName "mytestserver" -DocumentRoot /var/www/html/mytestserver -VirtualHostIPAddress * -VirtualHostPort 8090 | Out-Host 21 22 #Enumerate new set of virtual hosts 23 Write-Host -Foreground Blue "Enumerate Apache Virtual Hosts Again" 24 Get-ApacheVHost |Out-Host 25 26 #Cleanup 27 Write-Host -Foreground Blue "Remove demo virtual host" 28 if (Test-Path "/etc/httpd/conf.d"){ 29 & sudo rm "/etc/httpd/conf.d/mytestserver.conf" 30 } 31 if (Test-Path "/etc/apache2/sites-enabled"){ 32 & sudo rm "/etc/apache2/sites-enabled/mytestserver.conf" 33 }