#!/bin/bash

#作者:星云法师(头条号:西西图图---专注美食领域的研究)

#环境:centos7,如果是其它的系统可以相应做调整。
#--------选择安装方式,网络晚装还是本地安装--------------
read -p "Install nginx from internet or localpacke?answer i or l:" installway
installways=`echo $installway| tr [a-z] [A-Z]`
read -p "Install some need tools(Y/N):" needpack
needpacks=`echo $needpack| tr [a-z] [A-Z]`

#----是否要配置安装环境---------------------------
if [ "$needpacks" == "Y" ];then
    cd /etc/yum.repos.d
    mkdir -p /etc/yum.repo.bak
    mv /etc/yum.repos.d/* /etc/yum.repo.bak
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum clean all
    yum -y install openssh-clients wget gcc gcc-c++ install zlib zlib-devel openssl openssl-devel pcre-devel
elif [ "$needpacks" != "Y" ]&&[ "$needpacks" != "N" ];then
    echo "Input error!"
    exit 1
fi

#-----网络实际安装---------------------
if [ "$installways" == "I" ];then
    cd /tmp
    curl http://nginx.org/download/|awk -F'"' '{print $2}'|grep "nginx"|grep "tar"|awk -F'.tar' '{print $1}' >/tmp/nginxtmp.txt
    sort /tmp/nginxtmp.txt|uniq

#-------选择安装版本
    read -p "which version you want to install(input all you see):" version
    wget http://nginx.org/download/$version".tar.gz"
    tar xf $version".tar.gz"
        if [ $? -eq 0 ];then
            cd $version/
            groupadd nginx
            mkdir -p /var/cache/nginx
            useradd nginx -g nginx -s /sbin/nologin -M
            ./configure --user=nginx --group=nginx --prefix=/etc/nginx  --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-debug --with-stream --with-file-aio --with-threads --with-http_auth_request_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-mail --with-mail_ssl_module
            if [ $? -eq 0 ];then
                make && make install
                if [ $? -eq 0 ];then
                    echo "the bin in /usr/sbin/"
                    echo "Next is cmd about control nginx:"
                    echo "check nginx snock by \"/usr/sbin/nginx -t\""
                    echo "start nginx by \"/usr/sbin/nginx\""
                    echo "stop nginx  by \"/usr/sbin/nginx -s stop\""
                    echo "reload nginx  by \"/usr/sbin/nginx -s reload\""
                fi
            fi
        fi

#------本地安装--------------------
elif [ "$installways" == "L" ];then

#-----安装包来源主机---------------
    read -p "which ip your nginx packge from:" fromip

#-----安装包在远程主机的路径---------------
    read -p "which path your packge in:" path

#-----安装包版本,要全称--------------------
    read -p "which version your packge is(all name:nginx-1.14.2):" lversion

if [ "$fromip" != "" ]&&[ "$path" != "" ];then
        destpath=$fromip:$path$lversion
        scp root@$destpath /usr/local
        cd /usr/local
        tar xf $lversion".tar.gz"
        if [ $? -eq 0 ];then
            cd $lversion/
            groupadd nginx
            useradd nginx -g nginx -s /sbin/nologin -M
            ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module
            if [ $? -eq 0 ];then
                make && make install
                if [ $? -eq 0 ];then
                    echo "the bin in /usr/local/nginx/sbin/"
                fi
            fi
        fi
    fi
elif [ "$installways" != "I" ]&&[ "$installways" != "L" ];then
    echo "Input error!";exit 1
fi

nginx各版本全自动编译安装脚本的更多相关文章

  1. Nginx编译安装脚本

      Nginx是高性能的web服务器和反向代理服务器,在互联网公司中被广泛使用.以下是Nginx在centos7系统下的一键编译安装脚本,仅供参考,具体编译参数选项请结合实际生产环境需求进行选择,脚本 ...

  2. nginx-1.12.0版本(编译安装)-自定义安装路径

    nginx-1.12.0版本(编译安装)-自定义安装路径 安装路径:/application/nginx-1.12.0 1.前期准备 安装编译需要的gcc和gcc-c++ yum install -y ...

  3. 新安装和已安装nginx如何添加未编译安装模块/补丁

    新安装和已安装nginx如何添加未编译安装模块/补丁 --http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10485& ...

  4. php-fpm编译安装脚本

      PHP是开源.轻量级.高效的开发语言,特别适合web项目开发,在中小型互联网公司中常用于开发web后端.PHP常与Nginx及MySQL数据库结合,搭建LNMP环境.以下为centos7系统下ph ...

  5. bash-2 httpd服务的源码编译安装脚本

    httpd服务的源码编译安装脚本 #!/bin/bash # #******************************************************************** ...

  6. CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached

    声明:部分编译指令在博客编辑器里好像被处理了,如双横线变成单横线了等等,于是在本地生成了一个pdf版本,在下面地址可以下载. LNMP+Memcached CentOS是红帽发行的免费的稳定Linux ...

  7. shell脚本专题之-----------全自动编译安装mysql

    mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...

  8. shell脚本专题之-----------全自动编译安装mysql(免安装版)

    mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...

  9. CentOS 7.2mini版本下编译安装php7.0.10+MySQL5.7.14+Nginx1.10

    一.安装前的准备工作 1.yum update    #更新系统 2.yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2  ...

随机推荐

  1. EwoMail 邮件服务器安装

    ewomail 安装及使用 主页:http://www.ewomail.com/ 开源版主页:http://www.ewomail.com/list-9.html 开源版文档:http://doc.e ...

  2. FTP服务器原理及配置

    控制连接 21端口  用于发送ftp命令 数据连接 20端口  用于上传下载数据 数据连接的建立类型: 1主动模式: 服务器主动发起的数据连接 首先由客户端的21 端口建立ftp控制连接 当需要传输数 ...

  3. 【学习】006数据交换格式与SpringIOC底层实现

    课程目标 XML和JSON Java反射机制 手写SpringIOC 什么是数据交换格式 客户端与服务器常用数据交换格式xml.json.html 数据交换格式用场景 移动端(安卓.IOS)通讯方式采 ...

  4. (转)nginx+redis实现接入层高性能缓存技术

    转自:https://blog.csdn.net/phil_code/article/details/79154271 1. OpenRestyOpenResty是一个基于 Nginx与 Lua的高性 ...

  5. bzoj4811 [Ynoi2017]由乃的OJ 树链剖分+贪心+二进制

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4811 题解 我现在为什么都写一题,调一天啊,马上真的退役不花一分钱了. 考虑这道题的弱化版 N ...

  6. LOJ 2840「JOISC 2018 Day 4」糖

    有趣的脑子题(可惜我没有脑子 好像也可以称为模拟费用流(? 我们考虑用链表维护这个东西 再把贡献扔到堆里贪心就好了 大概就是类似于有反悔机制的贪心?我们相当于把选中的一个打上一个-v的tag然后如果选 ...

  7. jsp基础模板

    jsp页面基础模板 base.jsp <%@ page language="java" contentType="text/html; charset=UTF-8& ...

  8. python数据库操作-mysql数据库

    一:连接 1:本地连接 mysql -u用户名 -p密码 2:连接远程服务器 mysql -u用户名 -p密码 -hip地址 -P端口号     线下修改远程服务端上部署的mysql服务器 二:创建数 ...

  9. 如何在centos7中设置redis服务器开机自启动

    1.简单说明centos7系统中有不同类型的程序,一类是操作系统的服务程序,另一类是第三方程序,而redis就是第三方程序,每次关机后开机都要手工重新启动,很麻烦,那么如何把redis设置为开机自启动 ...

  10. windows 10 删除资源管理器导航栏 Creative Cloud Files

    安装完Adobe的Photoshop.After Effects等软件后,资源管理器导航栏会出现让人讨厌的Creative Cloud Files目录,稍微修改注册表即可删除. 快捷键Windows ...