博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NGINX虚拟主机脚本
阅读量:5290 次
发布时间:2019-06-14

本文共 2219 字,大约阅读时间需要 7 分钟。

#!/bin/bash#auto install Nginx virtual Hosts#by author ale#2019-4-30 15:17:57#define variablesNGINX_CONF="/usr/local/nginx/conf"NGINX_MAKE="--user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module"NGINX_SBIN="/usr/local/nginx/sbin/nginx"NGINX_INSTALL(){#Install Nginx serverNGINX_FILE=nginx-1.12.2.tar.gzNGINX_DIR=`echo $NGINX_FILE|sed 's/.tar*.*//g'`if [ ! -e /usr/local/nginx -a ! -e /etc/nginx ];then    pkill nginx    wget -c http://nginx.org/download/$NGINX_FILE    yum install pcre pcre-devel openssl openssl-devel -y    rm -rf $NGINX_DIR;tar xzf $NGINX_FILE    cd $NGINX_DIR;useradd www;./configure $NGINX_MAKE    make &&make install    grep -vE "#|^$" $NGINX_CONF/nginx.conf >$NGINX_CONF/nginx.conf.swp    \mv $NGINX_CONF/nginx.conf.swp $NGINX_CONF/nginx.conf    sed -i '/server/,$d' $NGINX_CONF/nginx.conf    #echo "}" >>$NGINX_CONF/nginx.conf    cd ../fi}NGINX_CONFIG(){#config nginx vhostsgrep "include domains" $NGINX_CONF/nginx.conf >>/dev/null 2>&1if [ $? -ne 0 ];then    #sed -i '$d' $NGINX_CONF/nginx.conf    echo -e "\ninclude domains/*;\n}">>$NGINX_CONF/nginx.conf    mkdir -p $NGINX_CONF/domains/fiVHOSTS=$1ls $NGINX_CONF/domains/$VHOSTS >>/dev/null 2>&1if [ $? -ne 0 ];then    #cp -r xxx.good.com $NGINX_CONF/domains/$VHOSTS    #sed -i "s/xxx/$VHOSTS/g" $NGINX_CONF/domains/$VHOSTS    cat>$NGINX_CONF/domains/$VHOSTS<
/data/www/$VHOSTS/index.html<

The First Test Nginx page.


$VHOSTS

EOF echo -e "033[32mThe $VHOSTS Config success,you can to access http://$VHOSTS/\033[0m" NUM=`ps -ef|grep nginx|grep -v grep|grep -v auto|wc -l` $NGINX_SBIN -t >>/dev/null 2>&1 if [ $? -eq 0 -a $NUM -eq 0 ];then $NGINX_SBIN else $NGINX_SBIN -t >>/dev/null 2>&1 if [ $? -eq 0 ];then $NGINX_SBIN -s reload fi fielse echo -e "\033[32mThe $VHOSTS has been config,please exit.\033[0m"fi}if [ -z $1 ];then echo -e "\033[32m------------\033[0m" echo -e "\033[32mPlease enter sh $0 xx.ale.com\033[0m" exit 0fiNGINX_INSTALLNGINX_CONFIG $1

 

转载于:https://www.cnblogs.com/legenidongma/p/10796996.html

你可能感兴趣的文章
P4438 [HNOI/AHOI2018]道路
查看>>
P1270 “访问”美术馆
查看>>
P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gather
查看>>
P3047 [USACO12FEB]附近的牛Nearby Cows
查看>>
P4084 [USACO17DEC]Barn Painting
查看>>
P2657 [SCOI2009]windy数
查看>>
P2602 [ZJOI2010]数字计数
查看>>
P1679 神奇的四次方数
查看>>
P1877 [HAOI2012]音量调节
查看>>
P2518 [HAOI2010]计数
查看>>
P1435 回文字串
查看>>
P4127 [AHOI2009]同类分布
查看>>
P2028 龙兄摘苹果
查看>>
P2880 [USACO07JAN]平衡的阵容Balanced Lineup
查看>>
P1970 花匠
查看>>
P1586 四方定理
查看>>
P1969 积木大赛
查看>>
P1965 转圈游戏
查看>>
#557. 蒟蒻KC的垃圾数列
查看>>
P2197 【模板】nim游戏
查看>>