一、首先安装必要的库nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库。选定/usr/local为安装目录,以下具体版本号根据实际改变。1.安装PCRE库$ cd /usr/local/$ wget ftp://ftp...

#!/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 "\033[32m-----------------\033[0m" echo -e "\033[32mUsage:{/bin/bash $0 1.2.3|1.12.2}\033[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 四、启动 $ /usr/local/nginx/sbin/nginx 检查是否启动成功: 打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。 部分命令如下: 重启: $ /usr/local/nginx/sbin/nginx –s reload 停止: $ /usr/local/nginx/sbin/nginx –s stop 测试配置文件是否正常: $ /usr/local/nginx/sbin/nginx –t 强制关闭: $ pkill nginx ? -----------未完待续-------------
织梦狗教程
本文标题为:Centos下Nginx源码安装与配置并附shell编程实现自动化安装


基础教程推荐
猜你喜欢
- windows环境下apache-apollo服务器搭建 2023-09-10
- Apache Kafka 2.5 稳定版发布,新特性抢先看 2023-09-11
- P3 利用Vulnhub复现漏洞 - Apache SSI 远程命令执行漏洞 2023-09-10
- Docker容器操作方法详解 2022-11-13
- 通过StatefulSet部署有状态服务应用实现方式 2022-10-01
- Centos 安装Django2.1 2023-09-24
- 为Win2003服务器打造铜墙铁壁的方法步骤 2022-09-01
- Centos7 nginx的安装以及开机自启动的设置 2023-09-22
- Apache CarbonData 1.0.0发布及其新特性介绍 2023-09-11
- RFO SIG之openEuler AWS AMI 制作详解 2022-12-28