Skip to content

Instantly share code, notes, and snippets.

@ericchen
Forked from cobbweb/example.conf
Created October 9, 2013 14:54
Show Gist options
  • Save ericchen/6902594 to your computer and use it in GitHub Desktop.
Save ericchen/6902594 to your computer and use it in GitHub Desktop.
server {
listen 8080;
server_name example.dev www.example.dev;
location / {
root /Users/Cobby/Sites/Example;
if ($host = 'www.example.dev' ) {
rewrite ^/(.*)$ http://example.dev:8080/$1 permanent;
}
if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css|less)$") {
rewrite ^(.*) /index.php last;
}
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
# expires max;
break;
}
}
# if the request starts with our frontcontroller, pass it on to fastcgi
location ~ \.php($|/)
{
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /Users/Cobby/Sites/Example$script;
fastcgi_param PATH_INFO $path_info;
include /usr/local/etc/nginx/fastcgi_params;
}
}
#user Cobby;
worker_processes 3;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
include /Users/Cobby/conf/nginx/*.conf;
}
#!/bin/bash
NGINX=`brew --prefix nginx`'/sbin/nginx'
PHPFPM=`brew --prefix php`'/sbin/php-fpm'
PHPFPMCONFIG=`brew --prefix php`'/etc/php-fpm.conf'
PIDPATH='/var/run'
if [ $1 = "start" ]; then
echo "Starting php-fpm ..."
sudo $PHPFPM -y $PHPFPMCONFIG
echo "Starting nginx ..."
sudo $NGINX
echo "Done!"
elif [ $1 = "stop" ]; then
echo "Stopping nginx ..."
sudo kill `cat $PIDPATH/nginx.pid`
echo "Stopping php-fpm ..."
sudo kill `cat $PIDPATH/php-fpm.pid`
echo "Done!"
elif [ $1 = "restart" ]; then
echo "Stopping nginx ..."
sudo kill `cat $PIDPATH/nginx.pid`
echo "Stopping php-fpm ..."
sudo kill `cat $PIDPATH/php-fpm.pid`
echo "Starting php-fpm ..."
sudo $PHPFPM
echo "Starting nginx ..."
sudo $NGINX
echo "Done!"
elif [ $1 = "nginx" ]; then
if [ $2 = "start" ]; then
echo "Starting nginx ..."
sudo $NGINX
elif [ $2 = "stop" ]; then
echo "Stopping nginx ..."
sudo kill `cat $PIDPATH/nginx.pid`
elif [ $2 = "restart" ]; then
echo "Stopping nginx ..."
sudo kill `cat $PIDPATH/nginx.pid`
echo "Starting nginx ..."
sudo $NGINX
else
echo "Valid commands for nginx: start | stop | restart"
fi
elif [ $1 = "php" ] || [ $1 = "php-fpm" ]; then
if [ $2 = "start" ]; then
echo "Starting php-fpm ..."
sudo $PHPFPM
elif [ $2 = "stop" ]; then
echo "Stopping php-fpm ..."
sudo kill `cat $PIDPATH/php-fpm.pid`
elif [ $2 = "restart" ]; then
echo "Stopping php-fpm ..."
sudo kill `cat $PIDPATH/php-fpm.pid`
echo "Starting php-fpm ..."
sudo $PHPFPM
else
echo "Valid commands for php-fpm: start | stop | restart"
fi
echo "Valid commands: "
echo "start | stop | restart"
echo "----------------------------------------"
echo "nginx (start | stop | restart)"
echo "php | php-fpm (start | stop | restart)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment