码迷,mamicode.com
首页 > 系统相关 > 详细

Linux7 自动化编译安装nginx-1.17.1

时间:2019-07-02 10:51:26      阅读:568      评论:0      收藏:0      [点我收藏+]

标签:lin   figure   useradd   openssl   Stub   error   func   download   dev   

##################################################
#Author:liluoluo
#Blog:https://blog.51cto.com/14101466
#mail:1276636807@qq.com
##################################################


#!/bin/bash
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
Install_path=/home/applications
Code_path=/home/usr
echo "------------------------start install nginx------------------------"
sleep 3
for soft in "gcc-c++" "zlib" "zlib-devel" "pcre" "pcre-devel" "openssl" "openssl-devel"
do
    if [[ ! `rpm -qa $soft|wc -l` -eq 1 ]];then
      yum install $soft -y
    else
      rpm -e $soft -y
      yum install $soft -y
    fi
done
if [ ! `grep nginx /etc/passwd|wc -l` -eq 1 ];then
  echo "adding user nginx....."
  useradd nginx -s /sbin/nologin -M
else
  echo "user nginx exsits"
fi
echo "------------environment installation c``ompleted------------"
sleep 2
echo "--------------------------download nginx-------------------------"
sleep 3
  [ -d $Code_path ] && cd $Code_path||mkdir $Code_path && cd $Code_path
    wget http://nginx.org/download/nginx-1.17.1.tar.gz
    tar -xf nginx-1.17.1.tar.gz
    cd nginx-1.17.1
echo "--------------------download completed-----------------------"
sleep 2
echo "-------------------------- install nginx----------------------------"
sleep 3
  [ -d $Install_path ]||mkdir $Install_path
./configure --prefix=$Install_path/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
  if [ $? -ne 0 ];then
    echo "configure failed ,please check it out!"
    exit 2
  else
    echo "make nginx, please wait for 20 minutes"
    make
  fi
  if [ $? -ne 0 ];then
    echo "make failed ,please check it out!"
    exit 3
  else
    echo "install nginx, please wait for 20 minutes"
    make install
      if [ $? -ne 0 ];then
        echo "make install error,please check it out"
        exit 4
      else
        echo "make install succeed!!!"
      fi
  fi
    chown -R nginx.nginx $Install_path/nginx
    ln -s $Install_path/nginx/sbin/nginx /usr/local/sbin/
    /usr/local/sbin/nginx
sleep 3
echo "-----------------nginx install succeed---------------------"

Linux7 自动化编译安装nginx-1.17.1

标签:lin   figure   useradd   openssl   Stub   error   func   download   dev   

原文地址:https://blog.51cto.com/14101466/2416102

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!