Apache, MySQL & PHP on OS X Mavericks
12 Jan 2014I hadn’t really anticipated using this blog any time soon, but since I just got asked a bunch of questions the other day about setting up Apache, php and MySQL on OS X 10.9 Mavericks this seemed to be a good occasion to recycle the following instructions.
Updated instructions for OS X 10.10 Yosemite are available here.
OS X 10.9 ships with both a recent version of Apache (2.2.x), as well as PHP (5.4.x), so you’ll just have to install MySQL. To get everything up and running only a few steps are required.
Apache
First, you have to create a web root in your user account:
Then add a configuration for your user:
If you want to use vhosts, you’ll have to make sure that the vhosts config gets loaded:
After that, configure vhosts as necessary in /etc/apache2/extra/httpd-vhosts.conf
(don’t forget to remove the examples in there).
PHP
PHP doesn’t get loaded by default. So we’ll also add it to our config:
You should also configure a few settings in /etc/php.ini
:
To activate these settings you have to restart Apache:
If you also need PEAR/PECL, follow these instructions.
MySQL
MySQL is not shipped with OS X, so we’ll have to install that manually. Instead of going for an installer package, we’ll use Homebrew. Once Homebrew is installed, installing MySQL is as simple as:
If you want to start MySQL automatically, the following command will do the trick:
Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻