Created
January 8, 2011 13:57
-
-
Save ikbear/770859 to your computer and use it in GitHub Desktop.
在服务器上添加一个网站,服务器为nginx,本脚本功能为添加网站的配置文件
This file contains 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
#!/bin/bash | |
# Usage: | |
# ./server.sh domain.com(without www) | |
# ./server.sh helishi.net | |
if [ "$*" = "" ] | |
then | |
exit; | |
fi | |
server="server {\n | |
\tlisten 80;\n | |
\tserver_name www.$* $*;\n | |
\tclient_max_body_size 20M;\n\n | |
\tlocation / {\n | |
\t\troot /home/ikbear/www/$*;\n | |
\t\tindex index.html index.htm index.php;\n | |
\t\tif (!-e \$request_filename){\n | |
\t\t\trewrite ^.*$ /index.php last;\n | |
\t\t}\n | |
\t\tcharset utf-8,gbk;\n | |
\t}\n\n | |
\tif (\$http_host ~* \"^$*\"){\n | |
\t\tset \$rule_0 1\$rule_0;\n | |
\t}\n | |
\tif (\$rule_0 = \"1\"){\n | |
\t\trewrite ^/(.*)$ http://www.$*/\$1 permanent;\n | |
\t\tbreak;\n | |
\t}\n\n | |
\t# pass the PHP scripts to FastCGI server listening on | |
var/run/php-fpm.sock\n | |
\tlocation ~ \.php$ {\n | |
\t\tautoindex on;\n | |
\t\troot /home/ikbear/www/$*/;\n | |
\t\tfastcgi_pass 127.0.0.1:9000;\n | |
\t\tfastcgi_index index.php;\n | |
\t\tfastcgi_param SCRIPT_FILENAME /home/ikbear/www/$* | |
\$fastcgi_script_name;\n | |
\t\tinclude fastcgi_params;\n | |
\t}\n | |
}\n" | |
mkdir /home/ikbear/www/$* | |
echo -e $server > /etc/nginx/sites-available/$* | |
ln -s /etc/nginx/sites-available/$* /etc/nginx/sites-enabled/$* | |
service nginx restart | |
echo "All DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment