These installation procedures will set up your mac with PHP 7.2 and Apache 2.4.
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew install httpd24 --with-privileged-ports --with-http2
sudo cp -v /usr/local/Cellar/httpd24/2.4.25/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
ps -aef | grep httpd
You should see something similar as output
0 23417 1 0 2:48PM ?? 0:00.06 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 23420 23417 0 2:48PM ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 23421 23417 0 2:48PM ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 23422 23417 0 2:48PM ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 23423 23417 0 2:48PM ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
1 23424 23417 0 2:48PM ?? 0:00.00 /usr/local/opt/httpd24/bin/httpd -D FOREGROUND
501 23428 403 0 2:48PM ttys000 0:00.00 grep httpd
Example:
brew unlink php70
Time to install latest PHP with the apache web server
brew install php --with-httpd24
Also make sure to set the following line in /usr/local/etc/apache2/2.4/httpd.conf
(You might need to disable others):
LoadModule php7_module /usr/local/opt/php72/libexec/apache2/libphp7.so
Also make sure you have set the following lines correctly:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
brew services restart httpd
brew services start php
Create a phpinfo.php
in /usr/local/var/www/htdocs
with the following contents:
<?php phpinfo(); ?>
You should see the famous PHP information page!
Uncomment these lines:
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
LoadModule userdir_module lib/httpd/modules/mod_userdir.so
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
in /usr/local/etc/apache2/2.4/httpd.conf
and edit the vhosts file.
Example vhosts:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /usr/local/var/www
</VirtualHost>
<VirtualHost *:8080>
# ServerAdmin [email protected]
DocumentRoot "/Users/USERNAME/Sites/EXAMPLE.com"
ServerName localhost
# ServerAlias www.dummy-host.example.com
ErrorLog "/usr/local/var/log/httpd/dev.EXAMPLE.com-error_log"
# CustomLog "/usr/local/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>