首页 / NGINX / nginx各版本全自动编译安装脚本
nginx各版本全自动编译安装脚本
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx各版本全自动编译安装脚本,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2614字,纯文字阅读大概需要4分钟。
内容图文
#!/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
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
#------本地安装--------------------
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
原文:https://www.cnblogs.com/xingyunfashi/p/11818623.html
内容总结
以上是互联网集市为您收集整理的nginx各版本全自动编译安装脚本全部内容,希望文章能够帮你解决nginx各版本全自动编译安装脚本所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。