Install Apache
- Execute the command below to install apache
choco install apache-httpd -y

Initialize Apache Configuration
- You can also download the script by clicking here
- Upon downloading, execute the command below to ensure you can execute the script
chmod u+x initialize-apache.sh
- From an administrative Powershell, execute the command below to identify the path of the apache directory
cd $env:systemdrive\
cmd /r dir /s /b "*ABOUT_APACHE.txt"

- From an administrative Powershell, execute the commands below replacing
"APACHE_PATH_HERE"
with the path fetched from the aforementioned command
#!/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"

- From a bash terminal, execute the command below
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
- Modify the
IfModule dir_module
section by adding the value index.php
before index.html
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

- From an administrative Powershell terminal, execute the following commands to restart apache
NET STOP apache
NET START apache