PEAR on OS X 10.9 Mavericks

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

cd /usr/lib/php
sudo php install-pear-nozlib.phar

If that fails

autoconf may be missing. To install it just use Homebrew. Once Homebrew is installed, installing autoconf is as simple as:

brew install autoconf

After autoconf is installed, try running the pear installer above again.

Upgrade PEAR

sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade-all

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.

xcode-select --install

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).

include_path = ".:/usr/lib/php/pear"

Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻

Apache, MySQL & PHP on OS X Mavericks

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:

mkdir ~/Sites

Then add a configuration for your user:

sudo tee /etc/apache2/users/$USER.conf <<EOF
<Directory "/Users/$USER/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
EOF

If you want to use vhosts, you’ll have to make sure that the vhosts config gets loaded:

sudo tee -a /etc/apache2/other/$USER-settings.conf <<EOF
Include /private/etc/apache2/extra/httpd-vhosts.conf
EOF

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:

sudo tee -a /etc/apache2/other/$USER-settings.conf <<EOF
LoadModule php5_module libexec/apache2/libphp5.so
EOF

You should also configure a few settings in /etc/php.ini:

sudo tee -a /etc/php.ini <<EOF
date.timezone = "`sudo systemsetup -gettimezone | awk '{print $3}'`"
display_errors = on
error_reporting = -1
EOF

To activate these settings you have to restart Apache:

sudo apachectl restart

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:

brew install mysql

If you want to start MySQL automatically, the following command will do the trick:

brew services start mysql

Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻

Don't hold your breath!

If I were you, I wouldn’t hold my breath for any actual content to show up here. But who knows - now that this is set up again:

Never say never.


Meanwhile

  • Check out fruux if you’re looking for a great tool to organize, sync & share contacts, calendars and tasks across platforms and devices.
  • Have a look at ec2dns if you’re managing a bunch of EC2 instances on AWS.
  • If building stuff is your thing, dig into our open source projects at fruux.

Any comments? Ping me on Twitter. 👉🏻 Get my newsletter for occasional updates. ✌🏻