Skip to content

Instantly share code, notes, and snippets.

@anderssvendal
Created May 3, 2012 13:44
Show Gist options
  • Select an option

  • Save anderssvendal/2585743 to your computer and use it in GitHub Desktop.

Select an option

Save anderssvendal/2585743 to your computer and use it in GitHub Desktop.
Foreman nginx, php, mysql setup

Install packages

You should have homebrew version 0.9 or newer.

Install nginx

brew install nginx

Install mysql

brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Install php

brew tap josegonzalez/homebrew-php
brew install php --with-mysql --with-fpm

Tweak php-fpm config

To run php-fpm in the foreground set deamonize = no in the php-fpm.conf. Should be located in /usr/local/Cellar/php/5.3.10/etc

Folder structure

Procfile
app
  <webapp goes here>
nginx.conf
tmp
  nginx
    logs
      access.log
      error.log
daemon off;
http {
include /usr/local/etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 3000;
server_name localhost;
root <absolute path to document root>;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$
{
include /usr/local/etc/nginx/fastcgi.conf;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
}
}
events {
}
web: /usr/local/sbin/nginx -p `pwd`/tmp/nginx/ -c ../../nginx.conf
fastcgi: /usr/local/sbin/php-fpm
db: /usr/local/bin/mysqld
@haggen
Copy link

haggen commented Nov 9, 2012

Man this is great, thanks! Only one problem I've got: php-fpm still running in background after I stopped foreman. Do you know what could it be since I already set daemonize = no in php-fpm.conf ?

@kinglouie
Copy link

i got the same problem, also tried with daemonize = no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment