Created
September 18, 2015 15:31
-
-
Save aindong/34defdaed02f1ae9a15c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z $1 ] | |
then | |
echo "serve www.domain.com /path" | |
exit 1 | |
fi | |
if [ -z $2 ] | |
then | |
echo "serve www.domain.com /path" | |
exit 1 | |
fi | |
string="$1" | |
#var=${string:4:100} | |
var="$1" | |
index="index.php" | |
block="server { | |
listen 80; | |
server_name $1; | |
root $2; | |
index index.html index.htm $index; | |
charset utf-8; | |
location / { | |
try_files \$uri \$uri/ /$index?\$query_string; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
access_log off; | |
error_log /usr/local/etc/nginx/logs/$var-error.log error; | |
error_page 404 /index.php; | |
sendfile on; | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_param SCRIPT_FILENAME \$request_filename; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_intercept_errors off; | |
fastcgi_buffer_size 16k; | |
fastcgi_buffers 4 16k; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
}" | |
echo "$block" >> "/usr/local/etc/nginx/sites-available/$var.conf" | |
ln -s "/usr/local/etc/nginx/sites-available/$var.conf" "/usr/local/etc/nginx/sites-enabled" | |
sudo nginx -s reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment