What I did was the following,
brew install php@7.3
php version 7.3.19 was installed.
Then edited my httpd.conf using
sudo nano /private/etc/apache2/httpd.conf
The following line in http.conf
LoadModule php7_module libexec/apache2/libphp7.so
was replaced with
LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
Added the following to http.conf right after modules block
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
In nano I searched for DirectoryIndex using ctrl+W
added index.php to finally make it
DirectoryIndex index.php index.html
Then I updated my PATH variable using
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> /Users/<your user>/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> /Users/<your user>/.bash_profile
Then I made a new directory sbin as following,
sudo mkdir /usr/local/sbin
Changed ownership to current user,
sudo chown -R $(whoami) /usr/local/sbin
Linked brew
brew link php@7.3 --force
Restarted Apache
sudo apachectl restart
Please Note: You do not have to probably do all of the steps or do it in same order, I only wanted to share what I did and worked for me.