#!/bin/bash #by LC IP=`ifconfig eth0|awk -F '[ :]+' 'NR==2{print $4}'` ZHANDIAN=/data01/static/share EXTRA=haixiang.conf SERVERNAME=lc.lc.org TOOLSDIR=/application/tools NGINXDIR=/application/nginx1.8.0 EXTARDIR=/application/nginx1.8.0/conf/extra ALIYUN=/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo NGINXBANEN=nginx-1.8.0 NGINX=http://nginx.org/download/${NGINXBANEN}.tar.gz panduan(){ if [ $? -ne 0 ] then echo "===============$1 NOT OK ====================" exit 1 fi } function checkNginxUser(){ if [ `cat /etc/passwd|grep nginx|wc -l` -eq 0 ] then useradd nginx -s /sbin/nologin -M fi } function checkNginxDir(){ [ ! -d $TOOLSDIR ] && mkdir -p $TOOLSDIR [ ! -d /app/ ] && mkdir -p /app [ ! -d $NGINXDIR ] && mkdir -p $NGINXDIR [ ! -d $EXTARDIR ] && mkdir -p $EXTARDIR } function checkYnmANDstart(){ wget -O $ALIYUN yum makecache yum install pcre pcre-devel -y yum install openssl openssl-devel -y cd $TOOLSDIR &&\ wget $NGINX tar xf $NGINXBANEN.tar.gz cd $NGINXBANEN ./configure --user=nginx --group=nginx --prefix=$NGINXDIR --with-http_stub_status_module --with-http_ssl_module panduan bianyi make panduan make make install cd ../ ln -s $NGINXDIR /application/nginx panduan link } function NGINXCONF(){ cat >$NGINXDIR/conf/nginx.conf<<AA worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #nginx vhosts config include extra/$EXTRA; } AA } function haixiangconf() { echo 'haixiang' >> $NGINXDIR/conf/extra/haixiang.conf cat >$NGINXDIR/conf/extra/$EXTRA <<AA server { listen 80; server_name $SERVERNAME; location / { root $ZHANDIAN; index index.html index.htm; } } AA pkill nginx pkill httpd $NGINXDIR/sbin/nginx } function FORcurl(){ if [ $(curl -I $IP|egrep "403|200|404"|head -1|wc -l) -eq 1 ] then echo "This is the start command :$NGINXDIR/sbin/nginx OR /application/nginx/sbin/nginx" echo "This is the reload command:$NGINXDIR/sbin/nginx -s reload" echo "This is the test command:$NGINXDIR/sbin/nginx -t" fi } main (){ checkNginxUser checkNginxDir checkYnmANDstart NGINXCONF haixiangconf FORcurl } main
shell之nginx安装+虚拟主机
原创LC_李闯 ©著作权
文章标签 shell nginx1.8.0 文章分类 Nginx 服务器
-
Nginx 之虚拟主机配置php html nginx
-
编译安装php/nginx/nginx虚拟主机
编译安装php/nginx,nginx虚拟主机配置
编译安装php/nginx