热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Centos7自动源码编译安装Nginx1.18..0脚本

#!binbash#Centos7源码安装nginx-1.18.0#2020年5月28日20:04:24#authorToyix######################

#!/bin/bash
#Centos7源码安装nginx-1.18.0
#2020年5月28日 20:04:24
#author Toyix
############################
repobase="/etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo"
repoepel="/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo"
soft1="vim wget lrzsz"
soft2="pcre-devel pcre gcc gcc-c++ openssl openssl-devel zlib-devel"
nginxversion="nginx-1.18.0"
nginxsoft="http://nginx.org/download/${nginxversion}.tar.gz"
nginxdir="/usr/local/nginx"
configuremoudule="--user=nginx \
--group=nginx \
--prefix=${nginxdir} \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_mp4_module \
--with-http_realip_module \
--with-pcre \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-stream"

netstat_nginx="netstat -tnlp |grep nginx"
selinuxconfigfile="/etc/selinux/config"
selinux_enforcing="SELINUX=enforcing"
selinux_disabled="SELINUX=disabled"
firewalld_open80="--zone=public --add-port=80/tcp --permanent"
firewalld_ports="--zone=public --list-ports"
yum install $soft1 -y
echo "安装国内base及epel源"
seleep 5
curl -o $repobase
wget -O $repoepel
yum clean all
yum makecache
echo "创建nginx用户nginx"
useradd -s /sbin/nologin -r nginx
echo "安装环境支持"
yum install $soft2 -y
echo "下载nginx"
cd /usr/src/
wget $nginxsoft
tar -xf ${nginxversion}.tar.gz
cd ${nginxversion}
echo "预编译"
./configure ${configuremoudule}
echo "编译"
make
echo "安装"
make install
${nginxdir}/sbin/nginx
sed -i "s/${selinux_enforcing}/${selinux_disabled}/g" ${selinuxconfigfile}
setenforce 0
firewall-cmd ${firewalld_open80}
firewall-cmd --reload
firewall-cmd $firewalld_ports
echo "------------------end"

------------end


推荐阅读
author-avatar
栋逼逼丶
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有