shell 及相关 / 平时应用 / 未分类 · 2016年7月28日

快速配置nginx虚拟主机(游戏入口快速搭建)

使用场景: 游戏的入口是 lnmp 环境,于是怕麻烦 就有了下面的sh
#!/bin/bash
# entran.sh
#合作方标识
echo -e "\033[31m Please input U gametag! \033[0m"
read games
#games=877wan
mkdir /data/www/${games}
echo "
" > /data/www/${games}/evan.php
echo "server {
listen 80;
server_name tm.${games}.game.com;
charset utf-8;
access_log off;
root /data/www/${games};
index index.php index.htm index.html;
location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|html|htm|mp3|wma|js|css)$ {
expires 7d;
}
location ~ .*\.php?$ {
include /usr/local/nginx/conf/fcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
error_page 404 /error/404.php;
}
" >/usr/local/nginx/conf/hosts/${games}.conf
/etc/init.d/nginx check
if [ $? -eq 0 ]
then
/etc/init.d/nginx restart
fi