Skip to content

Instantly share code, notes, and snippets.

@ultimagriever
Last active June 29, 2016 13:31
Show Gist options
  • Save ultimagriever/5128b966c6e73eaa4443b74d9fc2c88d to your computer and use it in GitHub Desktop.
Save ultimagriever/5128b966c6e73eaa4443b74d9fc2c88d to your computer and use it in GitHub Desktop.
nginx-new.sh
NGINX_PATH=/usr/local/etc/nginx
for f in ~/Sites/*; do
if [ -d $f ]; then # Is a directory
NGINX_CONF="$NGINX_PATH/sites-enabled/$(basename $f).dev"
echo $NGINX_CONF
cp $NGINX_PATH/template.dev $NGINX_CONF
sed -i '' "s/app/$(basename $f)/g" $NGINX_CONF
sed -i '' "s,nginx_path,$NGINX_PATH,g" $NGINX_CONF
if [ -d $f/public ]; then
sed -i '' "s,root_path,$f/public,g" $NGINX_CONF
else
sed -i '' "s,root_path,$f,g" $NGINX_CONF
fi
if [ -f $f/nginx_app.conf ]; then
echo "$f has nginx_app.conf"
sed -i '' "7a\\
include $f/nginx_app.conf;" $NGINX_CONF
fi
if [ -f $f/nginx_aliases.conf ]; then
echo "$f has nginx_aliases.conf"
sed -i '' "10a\\
include $f/nginx_aliases.conf;" $NGINX_CONF
fi
fi
done
sudo brew services restart nginx
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;
}
server {
listen 80;
server_name app.dev;
root root_path;
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