nosilence 发表于 2018-11-9 08:56:42

nginx+keepalived配置

#!/bin/bash  

  
cur_dir=$(pwd)
  
NGINXVERSION='nginx-1.6.0'
  
export LANG=zh_CN.UTF-8
  

  
#Source function library.
  
. /etc/init.d/functions
  

  
create_nginx_conf(){
  
cat >>/usr/local/nginx/conf/nginx.conf/etc/init.d/nginx>/etc/ld.so.conf
  
      ldconfig
  
      #download nginx package
  
      cd $cur_dir
  
      wget http://mirrors.sohu.com/nginx/$NGINXVERSION.tar.gz
  
      if [ $? -ne 0 ];then
  
                echo "download nginx is fail!!!"
  
                exit $?
  
      fi
  
      tar xf $NGINXVERSION.tar.gz
  
      cd $NGINXVERSION
  
         ./configure --user=www --group=www --prefix=/usr/local/$NGINXVERSION --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
  
         make && make install
  
      if [ $? -ne 0 ];then
  
                echo "install nginx fail!!!"
  
                exit $?
  
      fi
  
      #links
  
      ln -s /usr/local/$NGINXVERSION /usr/local/nginx
  
      ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
  
      mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
  
      #create file nginx.conf
  
      create_nginx_conf
  
      mkdir -p /var/www/default
  
      chmod +w /var/www/default
  
      mkdir -p /var/www/wwwlogs
  
      chmod 777 /var/www/wwwlogs
  
      chown -R www:www /var/www/default
  
      cp /usr/local/nginx/html/index.html /var/www/default/index.html
  
      #create start scripts for nginx
  
      create_nginx_init
  
      chmod +x /etc/init.d/nginx
  
      chkconfig --add nginx
  
      chkconfig nginx on
  
      /etc/init.d/nginx start
  
      if [ $? -eq 0 ];then
  
                action "start nginx" /bin/true
  
                echo "+---------------------------------+"
  
                echo "+------nginxinstall done--------+"
  
                echo "+---------------------------------+"
  
      fi
  
}
  

  
install_nginx


页: [1]
查看完整版本: nginx+keepalived配置