How to Setup PHP & MySQL on Mac OS X
If you’re a PHP developer on Mac OS X, you’ve probably heard of the applications MAMP or XAMPP. They are the easiest way to setup a local development environment with Apache, PHP, and MySQL (AMP stack). Having said that, Mac OS X comes with Apache and PHP out of the box. So, once you feel comfortable around your Mac, I recommend to experiment with setting up your own environment to gain more control and independence. It’s only four steps to configure:
1. Activate PHP
PHP isn’t launched on boot by default. To enable it, uncomment the following line in /etc/apache2/httpd.conf
:
LoadModule php5_module libexec/apache2/libphp5.so
2. Install Homebrew
Homebrew can be described as the missing package manager for OS X, and it makes installing MySQL a breeze.
3. Install MySQL via Homebrew
4. Secure MySQL
That’s it! In case you’d like to manage your databases with a GUI, you can install phpMyAdmin or use the free Mac app Sequel Pro.
To comfortably start, stop, and restart Apache and MySQL, I wrote the following shell script: