#!/bin/bash #2017年10月31日21:00:52 #auto install nginx soft #by author www.jfedu.net ####################### yum install gcc gcc-c++ glibc make zlib-devel pcre-devel -y wget -c http://nginx.org/download/nginx-1.12.1.tar.gz tar -xzf nginx-1.12.1.tar.gz cd nginx-1.12.1 ./configure --prefix=/usr/local/nginx/ make make install /usr/local/nginx/sbin/nginx
Nginx_v2.sh內容:html
#!/bin/bash #2017年10月31日21:00:52 #auto install nginx soft #by author www.jfedu.net ####################### NGINX_DIR="/usr/local/nginx" NGINX_VER="$1" NGINX_SOFT="nginx-${NGINX_VER}.tar.gz" NGINX_SRC="nginx-${NGINX_VER}" NGINX_URL="http://nginx.org/download" NGINX_LIB="gcc gcc-c++ glibc make zlib-devel pcre-devel" if [ -z $1 ];then echo -e "\033[32m------------------\033[0m" echo -e "\033[32mUsage:{sh $0 1.2.3|1.12.1|1.10.1}\033[0m" exit fi yum install $NGINX_LIB -y wget -c $NGINX_URL/$NGINX_SOFT tar -xzf $NGINX_SOFT cd $NGINX_SRC ./configure --prefix=$NGINX_DIR make make install $NGINX_DIR/sbin/nginx
Nginx_v3.sh內容:nginx
#!/bin/bash #2017年10月31日21:00:52 #auto install nginx soft #by author www.jfedu.net ####################### NGINX_DIR="/usr/local/nginx" NGINX_VER="1.12.1" NGINX_SOFT="nginx-${NGINX_VER}.tar.gz" NGINX_SRC="nginx-${NGINX_VER}" NGINX_URL="http://nginx.org/download" NGINX_LIB="gcc gcc-c++ glibc make zlib-devel pcre-devel" yum install $NGINX_LIB -y wget -c $NGINX_URL/$NGINX_SOFT tar -xzf $NGINX_SOFT cd $NGINX_SRC ./configure --prefix=$NGINX_DIR make make install $NGINX_DIR/sbin/nginx cd $NGINX_DIR/conf grep -vE "#|^$" nginx.conf>nginx.conf.swp cp nginx.conf.swp nginx.conf #for i in `seq 1 13`;do sed -i '$d' nginx.conf;done sed -i '/server/,$d' nginx.conf cat>>nginx.conf<<EOF server { listen 80; server_name www.jfjf1.com; location / { root html/www.jfjf1.com; index index.html index.htm; } } server { listen 80; server_name www.jfjf2.com; location / { root html/www.jfjf2.com; index index.html index.htm; } } EOF echo "}" >>nginx.conf mkdir -p ../html/www.jfjf{1,2}.com cat>../html/www.jfjf1.com/index.html<<EOF <h1>Welcome to nginx!</h1> <hr color=red> <h1>www.jfjf1.com</h1> EOF cat>../html/www.jfjf2.com/index.html<<EOF <h1>Welcome to nginx!</h1> <hr color=red> <h1>www.jfjf2.com</h1> EOF
/usr/local/nginx/sbin/nginx -s reload #重啓nginx服務c++