西大 发表于 2018-8-28 12:40:31

shell之nginx安装+虚拟主机

#!/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 $NGINXDIR/conf/extra/haixiang.conf
  
cat >$NGINXDIR/conf/extra/$EXTRA
页: [1]
查看完整版本: shell之nginx安装+虚拟主机