Skip to content

Instantly share code, notes, and snippets.

@bencooling
Last active December 19, 2015 06:49
Show Gist options
  • Save bencooling/5914525 to your computer and use it in GitHub Desktop.
Save bencooling/5914525 to your computer and use it in GitHub Desktop.
nginx: mac osx setup
export SHARE="/usr/share/php/var"
alias phpfpm-start="sudo $(brew --prefix josegonzalez/php/php55)/sbin/php-fpm"
alias phpfpm-stop="sudo kill $(cat $SHARE/run/php-fpm.pid)"
alias phpfpm-log="tail -f $SHARE/log/php-fpm.log"

##nginx: mac osx

nginx.conf
  • Configuration file for nginx
  • Located at: /usr/local/etc/nginx/nginx.conf
commands.sh
  • Common nginx related Bash commands for mac osx
# Test configuration files
sudo nginx -t
# Start server
sudo nginx
# Reload server
sudo nginx -s reload
# Stop server
nginx -s stop
# Start php-fpm
sudo $(brew --prefix josegonzalez/php/php55)/sbin/php-fpm
# Stop php-fpm (See installation.sh for relocation of .pid file)
SHARE="/usr/share/php/var"
sudo kill $(cat $SHARE/run/php-fpm.pid)
# Read/Write location for phpfm .pid, log, session files
sudo mkdir -p /usr/share/php/var/run \
sudo mkdir -p /usr/share/php/var/log \
sudo mkdir -p /usr/share/php/var/session
# Change ownership of directories to allow php-fpm access
cd /usr/share/php/
sudo chown -R bencooling:_www var/
# Edit php-fpm config file (/usr/local/etc/php/5.5/php-fpm.conf)
pid = /usr/share/php/var/run/php-fpm.pid
error_log = /usr/share/php/var/log/php-fpm.log
php_admin_value[session.save_path] = /usr/share/php/var/session
daemonize = yes #Process to run in background
user bencooling _www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
autoindex on; # View directories & their contents
server {
listen 80;
server_name localhost;
root html;
index index.php index.html index.html;
access_log $document_root/access.log;
include php.conf;
}
server {
listen 80;
server_name sandbox.dev;
root /Users/bencooling/Sites/sandbox;
index index.php index.html index.html;
access_log $document_root/access.log;
include php.conf;
}
# laravel
server {
listen 80;
server_name twit-off.dev;
root /Users/bencooling/Sites/twit-off/public;
index index.php index.html index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/usr/share/php/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
;;;;;;;;;;;;;;;;;;
; Bec Settings ;
;;;;;;;;;;;;;;;;;;
env[MYSQL_PASSWORD] = "root"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment