Skip to content

Instantly share code, notes, and snippets.

@ultimagriever
Created June 28, 2016 18:54
Show Gist options
  • Save ultimagriever/5eea2d516773239b0a4203de2473df65 to your computer and use it in GitHub Desktop.
Save ultimagriever/5eea2d516773239b0a4203de2473df65 to your computer and use it in GitHub Desktop.
Automatic Nginx Server Block Generation
# sh nginx.sh <app name>
APP=$1
if [[ $APP == "" ]]; then
echo "Please provide app name."
exit;
fi
NGINX_PATH=/usr/local/etc/nginx
cp $NGINX_PATH/sites-enabled/template.dev $NGINX_PATH/sites-enabled/$APP.dev
sed -i '' "s/app/$APP/g" $NGINX_PATH/sites-enabled/$APP.dev
echo "Config created for $APP"
cat $NGINX_PATH/sites-enabled/$APP.dev
sudo brew services restart nginx
server {
listen 80;
server_name app.dev;
root /Users/pamela/Sites/app/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
autoindex on;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?$query_string;
#fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment