My Apache MySQL PHP (MAMP) is a one-click-solution for setting up a fully-featured web application development environment on your computer. The MAMP suite is available for Macintosh and Windows platforms and enables you to work on your web projects locally, which is great for learning and testing purposes. It also eliminates the need to upload your content to a production web server to view your changes, which speeds up development time.

Download MAMP

Conveniently, there’s a single download for both MAMP & MAMP PRO software. (version 3.0.7.2 at time of writing):

http://downloads10.mamp.info/MAMP-PRO/releases/3.0.7.2/MAMP_MAMP_PRO_3.0.7.2.pkg

Verify download

In an age of ever-increasing threats to online security, it is imperative to verify the authenticity of packages downloaded from the Internets. You can use openssl to do this:

$ openssl sha1 MAMP_MAMP_PRO_3.0.7.2.pkg 
SHA1(MAMP_MAMP_PRO_3.0.7.2.pkg)= 83be4e601d4d456aeeaef9a3b98af50c8bae22ef

The above hash matches the hash published on the MAMP website, which confirms that the downloaded file is identical to the file stored online. We are now go for launch.

Double-click the MAMP_MAMP_PRO_3.0.7.2.pkg file to install the software.

Backup hosts file

The hosts file is important. I make a point of backing up key configuration files before modifying them, to create a ‘known good’ state to restore to (should I need it).

I simply create a copy of target file with .orig extension appended to the filename:

$ sudo cp /etc/hosts /etc/hosts.orig

Add custom domain to hosts file

Open the /etc/hosts file in your text editor of choice and append 127.0.0.1 example.local to the file and save it.

Backup Apache config file

Open Terminal and backup the Apache config file:

$ cp /Applications/MAMP/conf/apache/httpd.conf /Applications/MAMP/conf/apache/httpd.conf.orig

Add name-based virtual host to Apache config

Append your custom virtual host configuration to the httpd.conf file. An example

# My configuration:

NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Users/Example/path/to/website"
ServerName example.local
</VirtualHost>

The first VirtualHost block is needed to access the MAMP web apps (such as phpMyAdmin), so don’t change this.

You will need to edit the DocumentRoot and ServerName directives in second VirtualHost block as required.

Change MySQL root password

$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:

You will also need to update the password in the following files:

/Applications/MAMP/bin/phpMyAdmin/config.inc.php	# Line 87
/Applications/MAMP/bin/checkMysql.sh
/Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
/Applications/MAMP/bin/repairMysql.sh
/Applications/MAMP/bin/stopMysql.sh
/Applications/MAMP/bin/upgradeMysql.sh

Thanks to Chris Pauciello for posting this list on the Treehouse Forum.

That concludes this short guide to set up MAMP on OS X Yosemite. If you found this post useful, please do leave a comment below. Thanks for reading.

This article walks through the process of installing and configuring the wonderful open source MySQL backup tool automysqlbackup on OS X Yosemite. The easiest way to install the software is using the Homebrew package manager. If you need to install Homebrew, please follow the instructions on their website.

Install automysqlbackup via Homebrew

$ brew install automysqlbackup
==> Downloading https://downloads.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz
######################################################################## 100.0%
==> Caveats
You will have to edit
  /usr/local/etc/automysqlbackup/automysqlbackup.conf
to set AutoMySQLBackup up to find your database and backup directory.

The included plist file will run AutoMySQLBackup every day at 04:00.

To have launchd start automysqlbackup at login:
    ln -sfv /usr/local/opt/automysqlbackup/*.plist ~/Library/LaunchAgents
Then to load automysqlbackup now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.automysqlbackup.plist
==> Summary
🍺  /usr/local/Cellar/automysqlbackup/3.0-rc6: 6 files, 136K, built in 2 seconds

Backup the configuration file

It’s good practice to backup original configuration files:

$ cp /usr/local/etc/automysqlbackup/automysqlbackup.conf /usr/local/etc/automysqlbackup/automysqlbackup.conf.orig

Set root password

Open the automysqlbackup.conf file in your weapon of choice, uncomment line 21 and enter root password:

CONFIG_mysql_dump_password='password'

Lanch automysqlbackup at login

$ ln -sfv /usr/local/opt/automysqlbackup/*.plist ~/Library/LaunchAgents
/Users/Mike/Library/LaunchAgents/homebrew.mxcl.automysqlbackup.plist -> /usr/local/opt/automysqlbackup/homebrew.mxcl.automysqlbackup.plist

Load automysqlbackup

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.automysqlbackup.plist`

Create backup directory

Create backup directory and associated parent directories, as required:

$ mkdir -p /usr/local/var/backup

Add MySQL to PATH

If you try to run automysqlbackup now it will fail with "mysql ... not found. Aborting." because I need to tell my shell (Z shell) the path to the MySQL binaries. I’m using MAMP, so I need to point zsh to location of the MySQL binary files. The exact path is /Applications/MAMP/Library/bin. Please note, if you have installed MySQL seperately, you can probably skip this step.

If you’re using zsh (like me), edit your ~/.zshrc file. If you’re using bash, edit the ~/.bash_profile file. If you’re using another shell, please consult the respective manual. Either way, append this line to the end of the appropriate file:

PATH=$PATH:/Applications/MAMP/Library/bin

Test automysqlbackup

$ /usr/local/sbin/automysqlbackup
Invoking backup method.

Parsed config file "/usr/local/etc/automysqlbackup/automysqlbackup.conf"

# Checking for permissions to write to folders:
base folder /usr/local/var/backup ... exists ... ok.
backup folder /usr/local/var/backup/db ... exists ... writable? yes. Proceeding.
checking directory "/usr/local/var/backup/db/daily" ... exists.
checking directory "/usr/local/var/backup/db/weekly" ... exists.
checking directory "/usr/local/var/backup/db/monthly" ... exists.
checking directory "/usr/local/var/backup/db/latest" ... exists.
checking directory "/usr/local/var/backup/db/tmp" ... exists.
checking directory "/usr/local/var/backup/db/fullschema" ... exists.
checking directory "/usr/local/var/backup/db/status" ... exists.

# Testing for installed programs
WARNING: Turning off multicore support, since pigz isn't there.
mysql ... found.
mysqldump ... found.

# Parsing databases ... done.
======================================================================
AutoMySQLBackup version 3.0
http://sourceforge.net/projects/automysqlbackup/

Backup of Database Server - localhost
Databases - mysql,performance_schema,vielly
Databases (monthly) - mysql,performance_schema,vielly
======================================================================
======================================================================
Dump full schema.

Rotating 4 month backups for
Rotating 4 month backups for

======================================================================

======================================================================
Dump status.

Rotating 4 month backups for
Rotating 4 month backups for

======================================================================

Backup Start Time Fri Dec 26 13:20:04 GMT 2014
======================================================================
Weekly Backup ...

Weekly Backup of Database ( mysql )
Rotating 5 week backups for mysql
----------------------------------------------------------------------
Weekly Backup of Database ( performance_schema )
Rotating 5 week backups for performance_schema
----------------------------------------------------------------------
Weekly Backup of Database ( vielly )
Rotating 5 week backups for vielly
----------------------------------------------------------------------
Daily Backup ...

Daily Backup of Database ( mysql )
Rotating 6 day backups for mysql
----------------------------------------------------------------------
Daily Backup of Database ( performance_schema )
Rotating 6 day backups for performance_schema
----------------------------------------------------------------------
Daily Backup of Database ( vielly )
Rotating 6 day backups for vielly
----------------------------------------------------------------------

Backup End Time Fri Dec 26 13:20:14 GMT 2014
======================================================================
Total disk space used for backup storage...
Size - Location
472K /usr/local/var/backup/db

======================================================================

###### WARNING ######
Errors reported during AutoMySQLBackup execution.. Backup failed
Error log below..
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES

A final, optional (but highly recommended) step is to create a symbolic link (symlink) from the target backup directory to Dropbox:

$ ln -s /usr/local/var/backup/db ~/Dropbox/Backup/Venus/automysqlbackup

Now if disaster occurs and I’m unable to access the backed up databases on my MacBook Air, I can always access them from Dropbox.

That concludes this short guide to set up automysqlbackup on OS X Yosemite. If you found this post useful, please do leave a comment below. Thanks for reading.

I heart Jekyll and Jekyll hearts me. It’s a lean and mean static site generator blogging machine that enables you to ‘blog like a hacker’. One of the coolest features is the jekyll serve command, which serves up a local instance of your site, which can be accessed at http://localhost:4000.

Today when building my site locally I received two Build Warnings caused by the layout options in the feed.xml and sitemap.xml configuration files:

$ jekyll serve --watch
Configuration file: /Path/To/Jekyll/_config.yml
            Source: /Path/To/Jekyll
       Destination: /Path/To/Jekyll/_site
      Generating... 
     Build Warning: Layout 'none' requested in feed.xml does not exist.
     Build Warning: Layout 'nil' requested in sitemap.xml does not exist.
                    done.
 Auto-regeneration: enabled for '/Path/To/Jekyll'
Configuration file: /Path/To/Jekyll/_config.yml
    Server address: http://0.0.0.0:4000/
  Server running... press ctrl-c to stop.
Jekyll Layout Build Warnings

Fortunately, the fix is very simple:

  • Open file: /Path/To/Jekyll/Site/feed.xml
  • Change layout: none to layout: null
  • Open file: /Path/To/Jekyll/Site/sitemap.xml
  • Change layout: nil to layout: null
  • Marvel at your technical prowess.

Props to Michael Lee for sharing his solution.

Keep blogging like a boss.

Inspired by Jakob Lægdsmand’s fantasic how to get an awesome looking terminal on mac os x blog post, I switched my OS X Terminal from the humble Bash (Bourne Again SHell) to the Zsh (Z shell). I also installed Oh-My-Zsh, an open source, community-driven framework for managing Zsh’s configuration.

Before

A Bash OS X Terminal with Homebrew theme
A Bash OS X Terminal with Homebrew theme.

After

A Zsh OS X Terminal with Solarized (Dark) theme and Oh-My-Zsh eastwood theme
A Zsh OS X Terminal with Solarized (Dark) theme and Oh-My-Zsh eastwood theme.

Oh-My-Zsh is a thing of beauty. My shell and I are in a very happy place indeed!

__                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/

Welcome to the future of CSS layout: The CSS Flexible Box Layout Module (or Flexbox for short). It is a powerful new CSS box model optimised for user interface design. Look how easy it is to implement a Holy Grail page layout.

The HTML

<!doctype html>
<html lang="en">
<head>
<title>A Holy Grail Flexbox layout</title>
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="holy-grail.css">
</head>
<body class="holy-grail">
    <header>
        <h1>Header</h1>
    </header>
    <div class="holy-grail-body">
        <main class="holy-grail-content">
            <h2>Content</h2>
        </main>
        <nav class="holy-grail-nav">
            <h2>Navigation</h2>
        </nav>
        <aside class="holy-grail-sidebar">
            <h2>Sidebar</h2>
        </aside>
    </div>
    <footer>
        <h2>Footer</h2>
    </footer>
</body>
</html>

The CSS

body {
        background: #c4d1d1;
}
.holy-grail {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    width: 80%;
    margin: 0 auto;
}
.holy-grail-body {
    display: flex;
    flex: 1;
}
.holy-grail-content {
    flex: 1;
    background: #ffc94e;
}
.holy-grail-nav, .holy-grail-sidebar {
    /* 12em is the width of the columns */
    flex: 0 0 12em;
    background: #c9ea5d;
}
.holy-grail-nav {
    /* put the nav on the left */
    order: -1;
    background: #85d6e4;
}
header
{
    background: #92e4c9;
}
footer
{
    background: #f7846a;
}
* {
    color: #333;
}

Which yields the following:

A Holy Grail Flexbox layout
A Holy Grail Flexbox layout.

For more information about Flexbox, check out the comprehensive A Complete Guide to Flexbox article on CSS-Tricks.