OS X 10.10 ships with both a recent version of Apache (2.4.x), as well as PHP (5.5.x), so you’ll just have to install MySQL and go through a few steps to get everything up and running.
Apache
First, you have to create a web root in your user account:
Then add a configuration for your user:
Now we have to make sure that our user config above actually gets loaded:
If you want to use vhosts, you’ll also 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).
It seems that mod_rewrite no longer gets loaded by default, so we’ll also add that to our config:
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:
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 Caveats section from the output of the following command will show you how:
Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻
If you haven’t heard about Docker, this post will be of little interest, but if you also have started dockering-all-the-things you might have run into the limited log handling capabilities for Docker containers (Docker v0.8.0 is the current version at the time of writing), too. I especially noticed this when trying to run NGINX inside a container.
Being able to attach /dev/log of the host system to /dev/log inside a container (by adding a -v /dev/log:/dev/log parameter to docker run) made it seem like a quick fix - but only until you notice this hint in the NGINX docs:
Luckily there is an open source syslog patch for NGINX on GitHub. Below is a quick and dirty Dockerfile for an Ubuntu 13.10 container with a patched NGINX version.
There are a few things missing (e.g. NGINX php-fpm config, adding your application, actually configuring NGINX to use syslog), but you’ll probably figure that out.
Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻
Like previous versions of OS X, 10.9 also ships with PEAR. Installing and activating it is easy. Once that’s done PEAR and PECL work as expected (if you also want to set up and install Apache, PHP and MySQL, check this post).
Updated instructions for OS X 10.10 Yosemite are available here.
Installing PEAR
If that fails
autoconf may be missing. To install it just use Homebrew. Once Homebrew is installed, installing autoconf is as simple as:
After autoconf is installed, try running the pear installer above again.
Upgrade PEAR
Xcode Command Line Developer Tools
You will run into problems installing pecl extensions, if you don’t have the Xcode Command Line Extensions installed, so we’ll also install them.
Configuring PHP
Open /etc/php.ini and add .:/usr/lib/php/pear to include_path (if /etc/php.ini does not exist, create it with the following content).
Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻
I 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:
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. ✌🏻