Jason McCreary has provided a tutorial on his site today for all of the OS X Mojave users out there about how to install Apache, PHP and MySQL on macOS with the latest operating system changes. This is an update of his previous post covering the same installation on OSX Sierra.
I am aware of the web server software available for macOS, notably MAMP, as well as package managers like brew. These get you started quickly. But they forego the learning experience and, as most developers report, can become difficult to manage.
The thing is macOS runs atop UNIX. So most UNIX software installs easily on macOS. Furthermore, Apache and PHP come preinstalled with macOS. To create a local web server, all you need to do is configure Apache and install MySQL.
He walks you through the full process to get everything up and running:
- testing to ensure Apache can be started (it comes installed by default)
- changing the configuration to enable PHP
- making a
phpinfopage in your
DocumentRootto test that PHP is working
- downloading and installing MySQL
- configuration changes required to connect PHP and MySQL
He also includes an example of additional changes such as enabling
mod_rewrite and a link to a tutorial about setting up virtual hosts on your local machine.