2020-03-24 19:08:37 +01:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2018-02-13 18:23:53 +01:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2016-08-17 21:07:12 +02:00
|
|
|
Import-Module $PSScriptRoot/Apache/Apache.psm1
|
2016-07-25 22:51:37 +02:00
|
|
|
|
|
|
|
#list Apache Modules
|
2016-08-17 21:07:12 +02:00
|
|
|
Write-Host -Foreground Blue "Get installed Apache Modules like *proxy* and Sort by name"
|
2017-07-22 06:03:49 +02:00
|
|
|
Get-ApacheModule | Where-Object {$_.ModuleName -like "*proxy*"} | Sort-Object ModuleName | Out-Host
|
2016-07-25 22:51:37 +02:00
|
|
|
|
|
|
|
#Graceful restart of Apache
|
2016-08-17 21:07:12 +02:00
|
|
|
Write-host -Foreground Blue "Restart Apache Server gracefully"
|
|
|
|
Restart-ApacheHTTPServer -Graceful | Out-Host
|
2016-07-25 22:51:37 +02:00
|
|
|
|
|
|
|
#Enumerate current virtual hosts (web sites)
|
2016-08-17 21:07:12 +02:00
|
|
|
Write-Host -Foreground Blue "Enumerate configured Apache Virtual Hosts"
|
|
|
|
Get-ApacheVHost |out-host
|
2016-07-25 22:51:37 +02:00
|
|
|
|
|
|
|
#Add a new virtual host
|
2016-08-17 21:07:12 +02:00
|
|
|
Write-Host -Foreground Yellow "Create a new Apache Virtual Host"
|
2016-09-14 19:50:44 +02:00
|
|
|
New-ApacheVHost -ServerName "mytestserver" -DocumentRoot /var/www/html/mytestserver -VirtualHostIPAddress * -VirtualHostPort 8090 | Out-Host
|
2016-07-25 22:51:37 +02:00
|
|
|
|
|
|
|
#Enumerate new set of virtual hosts
|
2016-08-17 21:07:12 +02:00
|
|
|
Write-Host -Foreground Blue "Enumerate Apache Virtual Hosts Again"
|
|
|
|
Get-ApacheVHost |out-host
|
|
|
|
|
|
|
|
#Cleanup
|
|
|
|
Write-Host -Foreground Blue "Remove demo virtual host"
|
|
|
|
if (Test-Path "/etc/httpd/conf.d"){
|
|
|
|
& sudo rm "/etc/httpd/conf.d/mytestserver.conf"
|
|
|
|
}
|
|
|
|
if (Test-Path "/etc/apache2/sites-enabled"){
|
|
|
|
& sudo rm "/etc/apache2/sites-enabled/mytestserver.conf"
|
|
|
|
}
|