Created
June 24, 2014 15:05
-
-
Save benphelps/c701235d321de4cefcc3 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/php | |
<?php | |
$block = "server { | |
listen 80; | |
root /usr/share/nginx/html/{$argv[1]}; | |
index index.php index.html index.htm; | |
server_name {$argv[1]}; | |
location / { | |
try_files \$uri \$uri/ =404; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location ~ \.php$ { | |
try_files \$uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
}"; | |
mkdir("/usr/share/nginx/html/{$argv[1]}"); | |
touch("/usr/share/nginx/html/{$argv[1]}/index.html"); | |
file_put_contents("/etc/nginx/sites-available/{$argv[1]}", $block); | |
symlink("/etc/nginx/sites-available/{$argv[1]}", "/etc/nginx/sites-enabled/{$argv[1]}"); | |
system('sudo service nginx reload'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment