Chris Mallinson Chris Mallinson at night
Chris Mallinson

Local Web Development with macOS Mojave

Posted on September 21, 2018

My guide for setting up a great web development environment on your Mac, which was originally written with OS X 10.8 (Mountain Lion) in mind, updated for Mavericks, and then overhauled for Yosemite, has now been confirmed to work with macOS Mojave (10.14).

If you had previously used my tutorial, and upon upgrading to Mojave, your localhost has stopped working, it’s likely that you may need to restore your Apache config files.

When the Mojave updater runs, it replaces your edited Apache configuration files with the default ones, wiping out any changes you have made. The good news is that there is a back up of your config files.

Running the following commands will restore your previous Apache configuration, and restart apache:

sudo cp /etc/apache2/httpd.conf~previous /etc/apache2/httpd.conf

sudo cp /etc/apache2/extra/httpd-vhosts.conf~previous /etc/apache2/extra/httpd-vhosts.conf

sudo apachectl restart

This alone should restore your settings, and kick start your old environment under Mojave, but if you’re using PHP, there’s another step. Mojave comes with PHP7, so if you’re upgrading from a version prior to High Sierra (10.13) you need to alter a few lines from your Apache configuration.

168  LoadModule rewrite_module libexec/apache2/mod_rewrite.so
169  LoadModule php5_module libexec/apache2/libphp5.so
170  #LoadModule perl_module libexec/apache2/mod_perl.so

becomes

168  LoadModule rewrite_module libexec/apache2/mod_rewrite.so
169  LoadModule php7_module libexec/apache2/libphp7.so
170  #LoadModule perl_module libexec/apache2/mod_perl.so

Then restart apache and you should be good to go.

sudo apachectl restart

If you have not yet upgraded, I would encourage you to first make your own backup of your config file, just in case your upgrade fails, and you need to start from scratch.