nginx源码安装 shell编程

Posted anwar

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx源码安装 shell编程相关的知识,希望对你有一定的参考价值。

#!/bin/bash
#--------------------------------------------------------
# Function: Install nginx for CentOS7
# Date: 2018-1-06
# Author: Anwar Wong
#--------------------------------------------------------
#Print debug information
 
NGINX_VER="$?"
NGINX_SOFT="nginx-${NGINX_VER}.tar.gz"
NGINX_URL="http://nginx.org/download"
NGINX_DIR="/usr/local/nginx"
NGINX_SRC=`echo $NGINX_SOFT| sed ‘s/.tar.*//g‘`
NGINX_YUM="yum install -y"
NGINX_ARG="--user=www --group=www --with-http_stub_status_module --with-http_ssl_module"
 
 
if [$? -eq 0]; then
      echo -e "33[32m-----------------33[0m"
echo -e "33[32mUsage:{/bin/bash $0 1.2.3|1.12.2}33[0m"
exit 0
fi
#Installing dependencies
$NGINX_YUM wget make tar gcc gcc-c++ glibc zlib zlib-devel 
$NGINX_YUM perl perl-devel pcre pcre-devel openssl openssl-devel
 
#Downloading
wget -c $NGINX_URL/$NGINX_SOFT
tar -xzf $NGINX_SOFT
cd $NGINX_SRC
 
#Creating user and group
useradd -s /sbin/nologin www
 
#Starting install nginx
./configure --prefix=$NGINX_DIR/$NGINX_ARG
 
#Compile nginx
make -j4
make -j4 install
 
#Starting Nginx
$NGINX_DIR/sbin/nginx
 
#Show nginx status
ps -ef |grep nginx
netstat -tnlp |grep nginx
 

以上是关于nginx源码安装 shell编程的主要内容,如果未能解决你的问题,请参考以下文章

shell脚本:lnmp等源码安装脚本

shell脚本之一键源码安装nginx软件包

shell 脚本之一键部署安装 Nginx

centos7 源码编译安装nginx教程 nginx安装脚本

源码安装Nginx和PHP

Nginx 实践案例(源码编译安装方式):利用LNMP搭建wordpress站点