A blog about things I like

Recently I've got a new MacBook Pro and decided to set it up from scratch, because I use the same Time Machine backup to migrate from since about four years. Perfect time to get rid of the web server/LAMP (Linux Apache MySQL PHP) stack and replace it with Nginx and PHP-FPM as FastCGI implementation. Below you can read how to setup Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X 10.9 / Mavericks.

Updated for Yosemite users: Updated the guide for 10.10 since Yosemite is officially released. The steps are basically the same as for Mavericks.

Xcode

First of all, get the latest Xcode version (6.1) via the Mac App Store:

As soon as you've finished the download, open Xcode in your /Applications folder and agree to the licence.

Open a new Terminal window and install the Xcode Command Line Tools:

xcode-select --install

Confirm the installation dialog with Install.

Back in Xcode, hit ⌘ + , to access the Preferences and navigate to the Locations tab. Set the Command Line Tools to the latest version available , Xcode 6.1 (61A1052c) in my example:

Make sure you use at least Xcode 6.1!

Homebrew

Now we need to install Homebrew, which is a package manager for OS X. You probably already heard about apt-get or aptitude on Linux distributions to install packages or depencies for a specific application. brew works the same, just on Mac operating systems. It will also make sure that you will get the latest updates of the installed packages as well, so you don't need to worry about outdated versions or vulnerable security flaws and exploits either.

First, we need to download and install Homebrew using the following command:

PHP-FPM

MySQL

FAQ

Here are some of the frequently asked questions out of the comment section below. In case you have any issue or problem, try to check below if you find your problem listed.

Nginx: [emerg] mkdir() "/usr/local/var/run/nginx/client_body_temp"

Upgraded to Yosemite and now Nginx doesn't start anymore? Try to reinstall the brew formula:

brew reinstall --force nginx

PHP-FPM: lsof -Pni4 | grep LISTEN | grep php doesn't return anything

Make sure your $PATH variable is properly set:

echo $PATH | grep php56

If that command doesn'T return anything you probably forgot to adjust your .zshrc/.bash_profile. Make sure to add this line at the end:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

git: Could not resolve host: git.frd.mn

Probably an outage of my private hosted GitLab server. To fix this, simply try to get in contact with me. Either via Twitter, E-Mail IRC (frdmn@freenode/espernet) or the comment section below. I'll try to respond as soon as possible and fix potential issues.

curl: Failed to connect to localhost port 80: Connection refused

This is an IPv6 related issue, originating in the /etc/hosts file of your Mac. To fix this, find the line "fe80::1%lo0 localhost" and comment it out. Or just use this one liner:

sudo sed -i "" 's/^fe80\:\:/\#fe80\:\:/g' /etc/hosts

brew: configure: error: Can not find OpenSSL's <evp.h>

Make sure Xcode as well as Xcode's CLI tools as installed and up to date!