Install Apache

choco install apache-httpd -y

Initialize Apache Configuration

#!/usr/bin/env pwsh

echo "=========================================="
echo "initializing variables"
echo "=========================================="
$apachePath="C:\Users\hunte\AppData\Roaming\Apache24\" # set apache directory path
$apacheConfigPath="$apachePath/conf"
$apacheHttpdConfigPath="$apacheConfigPath/httpd.conf" # fetch apache config directory path

echo "=========================================="
echo "backing up config"
echo "=========================================="
copy "$apacheHttpdConfigPath" "$apacheConfigPath/httpd.backup.conf"

echo "=========================================="
echo "initializing config"
echo "=========================================="
(gc "$apacheHttpdConfigPath").replace('Listen 0.0.0.0:80','Listen 0.0.0.0:8080') | sc "$apacheHttpdConfigPath"
(gc "$apacheHttpdConfigPath").replace('Listen [::0]:80','Listen [::0]:8080') | sc "$apacheHttpdConfigPath"
(gc "$apacheHttpdConfigPath").replace('ServerName localhost:80','ServerName localhost:8080') | sc "$apacheHttpdConfigPath"

Configure Apache to Use PHP

apachePath="C:\Users\hunte\AppData\Roaming\Apache24" # set apache 
apacheConfigPath="$apachePath/conf"
apacheHttpdConfigPath="$apacheConfigPath/httpd.conf" # fetch apache config directory path
phpPath=`which php` # fetch php executatble path
phpParentPath="$(dirname "$phpPath")" # fetch php parent directory path
phpParentPathWindows=`cygpath -d $phpParentPath` # convert from bash string to dos string

echo "
AddHandler application/x-httpd-php .php^
AddType application/x-httpd-php .php .html^
LoadModule php7_module \"$phpParentPath/php8apache2_4.dll\"^
PHPIniDir \"$phpParentPath\"
" >> $apacheHttpdConfigPath
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

NET STOP apache
NET START apache