美文网首页
nginx编译安装脚本

nginx编译安装脚本

作者: linux_python | 来源:发表于2020-03-03 14:53 被阅读0次

!/bin/bash

--------------------------------------------------------

Function: Install nginx for CentOS7

Date: 2019-12-2

Author: Ma Ning

--------------------------------------------------------

Print debug information

NGINX_VER="?" NGINX_SOFT="nginx-1.16.1.tar.gz" NGINX_URL="http://nginx.org/download/nginx-1.16.1.tar.gz" NGINX_DIR="/usr/local/nginx" NGINX_SRC=`echoNGINX_SOFT| sed 's/.tar.*//g'`
NGINX_YUM="yum install -y"
NGINX_ARG="--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module"

userdel -r nginx
if [ ? -eq 0 ]; then echo -e "\033[32m-----------------\033[0m" echo -e "\033[32mUsage:{/bin/bash0 1.2.3|1.12.2}\033[0m"
fi

Installing dependencies

echo "正在安装环境,请稍后!!!"
NGINX_YUM wget make tar gcc gcc-c++ glibc zlib zlib-devel &>/dev/nullNGINX_YUM perl perl-devel pcre pcre-devel openssl openssl-devel &>/dev/null
echo "环境已经安装,正在下载nginx"

Downloading

wget -c NGINX_URL tar -xzfNGINX_SOFT
cd $NGINX_SRC

Creating user and group

groupadd -g 110 nginx
useradd -u 990 -g 110 -s /sbin/nologin -M nginx

Starting install nginx

./configure $NGINX_ARG

Compile nginx

make && make install
if [ $? -eq 0 ];then
echo "安装成功,正在启动,请稍后!!!"
else
echo "安装失败,请检查!!!"
fi

Starting Nginx

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginxctl
nginxctl
if [ $? -eq 0 ];then
echo "nginx启动成功"
else
echo "启动失败"
fi

Show nginx status

ps -ef |grep nginx
netstat -tnlp |grep nginx

相关文章

网友评论

      本文标题:nginx编译安装脚本

      本文链接:https://www.haomeiwen.com/subject/vbzfgctx.html