Simple Mavericks WordPress test environment

Software

PHP, Apache, MariaDB, SeaMonkey Broser, OS X Mavericks!

There's more than one way to skin a grape, and so many other tools to use. If you want a quick WordPress test environment without installing a package like MAMP and XAMPP, you could do worse than follow what I did recently. How's that for an intro, and a cliché stack image? ^_^

Ingredients

  • Apache2 in OS X 10.9 Mavericks
  • PHP 5.5 from Homebrew
  • MariaDB from Homebrew
  • WordPress from WordPress.org

Getting Homebrew and Developer Tools

Homebrew is a wonderful new package manager for Mac. Download it as per the site instructions, or just run the following:

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Then confirm and update all is working:

% brew doctor
% brew update

During the process of installing Homebrew packages, OS X may ask you to download Developer Tools if you don't have them installed. Or you can just download them from the Apple Developer site.

Getting PHP

The lovely josegonzalez maintains a PHP repository we can use, which also requires the dupes repo.

% brew tap homebrew/dupes
% brew tap josegonzalez/homebrew-php
% brew install php55

If you'd rather use nginx here, install php55 like this instead.

% brew install php55 --without-apache --with-fpm

Now we just add our new php install to OS X's Apache2 configuration. If you use TextMate, open it as such:

% sudo mate /etc/apache2/httpd.conf

And add the following line after the block of LoadModules:

LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so

Getting MariaDB

MariaDB is an enhanced, drop in replacement for MySQL that is fully compatible with WordPress. It's where the community energy behind the platform seems to be thesedays, though all the installed tools still use the "mysql" moniker for now.

% brew install mariadb

After installing, copy the launch script, and start the server. Many other tutorial sites online have you copy the plist file instead; creating a symlink helps to ensures it will still work if you update your brews.

% ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents
% launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

Setting up MariaDB for WordPress

Now we can set up our server and tables for WordPress! First, run the secure script and define a root password. You can safely remove the test tables and such:

% mysql_secure_installation

Next, we'll login with our new root credentials:

% mysql -uroot -p

Then create a WordPress database and user to access it. I used "wordpress" to keep things simple, though you should use a better passphrase!

MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* 
TO 'wordpress' IDENTIFIED BY 'passphrase';
MariaDB [(none)]> q

Installing WordPress, starting Apache

Download and extract WordPress into the document root, which is:

% cd /Library/WebServers/Documents/
% sudo -s
# curl -O 'http://wordpress.org/latest.tar.gz'
# tar xzvf latest.tar.gz

This is optional, but so WordPress wouldn't ask us for FTP credentials when installing plugins or importing posts, I changed the owner of the document root to www:

% sudo chown -R www wordpress

Now we can run Apache, and install WordPress as we would on any web host. Done and done!

% sudo apachectl start

Author bio and support

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.