Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Created January 26, 2012 17:40
Show Gist options
  • Save christianchristensen/1683963 to your computer and use it in GitHub Desktop.
Save christianchristensen/1683963 to your computer and use it in GitHub Desktop.
nginx + php OSX local

(originally from: http://elytra.net/2011/03/31/hello-world/)

Howto

Install nginx+PHP:

brew install https://raw.github.com/ampt/homebrew/php/Library/Formula/php.rb --with-fpm --with-mysql --enable-cgi
brew install nginx

Configure your /usr/local/etc/nginx/nginx.conf (similar to):

server {
    listen       80;
    server_name  localhost;
    root   /path/to/phpfiles;
    index  index.php index.html index.htm;
 
    location / {
        # http://www.ruby-forum.com/topic/187939
        # error_page 405 = $uri;
    }
 
    location ~ .php {
         include fastcgi_params;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME /path/to/phpfiles$fastcgi_script_name;
    }
}

Start your servers:

/usr/local/sbin/php-fpm
/usr/local/sbin/nginx -c /usr/local/etc/nginx/nginx.conf

Notes:

  • Pay attention to the PHP version that was installed (e.g. 5.3.9 in this example...)
  • You can access you php.ini settings in /usr/local/Cellar/php/5.3.9/etc/php.ini
  • nginx settings are in /usr/local/etc/nginx/nginx.conf
  • memcached -m 128 -d
  • Pay attention to the ports that php-fpm and nginx.conf are set to connect... xdebug likes 9000 as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment