larrybotha
3/21/2012 - 10:34 AM

Install Nginx + PHP-fpm + MySQL on Mac OS X Lion 10.7.2

Install Nginx + PHP-fpm + MySQL on Mac OS X Lion 10.7.2

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.php.php-fpm</string>
<key>ProgramArguments</key>
<array>
    <string>/usr/local/sbin/php-fpm</string>
    <string>--fpm-config</string>
    <string>/usr/local/Cellar/php/5.3.8/etc/php-fpm.conf</string>
</array>
<key>Debug</key><false/>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><false/>
<key>UserName</key><string>username</string>
</dict>
</plist>
# First install requirements for BREW
# http://mxcl.github.com/homebrew/
# https://github.com/mxcl/homebrew/wiki/installation
# Requirements
#  - An Intel CPU 2
#  - OS X 10.5 or higher
#  - Command Line Tools for Xcode (https://developer.apple.com/downloads)
#        or Xcode with X11 (http://itunes.apple.com/us/app/xcode/id448457090)
#  - Java Developer Update (https://connect.apple.com/)

# Install BREW
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

# Install nginx
brew install nginx

# Create a link to autostart nginx when the system starts
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.0.10/org.nginx.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist

# Cancel the self-starting
launchctl unload -w ~/Library/LaunchAgents/org.nginx.nginx.plist

# Install MySQL
brew install mysql
# Configuration start MySQL
# * if this is your first install:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/mysql/5.5.19/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# * if this is an upgrade and you already have the homebrew.mxcl.mysql.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    cp /usr/local/Cellar/mysql/5.5.19/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# m4 macros were installed to "share/aclocal".
# Homebrew does not append "/usr/local/share/aclocal"
# to "/usr/share/aclocal/dirlist". If an autoconf script you use
# requires these m4 macros, you'll need to add this path manually.

# Install PHP
brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/php.rb --without-apache --with-intl --with-fpm --with-mysql

# Configuration
mkdir /usr/local/Cellar/php/5.3.10/var/log
cp /usr/local/Cellar/php/5.3.10/etc/php-fpm.conf.default /usr/local/Cellar/php/5.3.10/etc/php-fpm.conf
mate /usr/local/Cellar/php/5.3.10/etc/php-fpm.conf

chmod -R ug+w /usr/local/Cellar/php/5.3.10/lib/php
pear config-set php_ini /usr/local/etc/php.ini