一、首先安装必要的库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编程实现自动化安装


猜你喜欢
- 利用Docker 运行 python 简单程序 2022-10-16
- nginx中封禁ip和允许内网ip访问的实现示例 2022-09-23
- 阿里云ECS排查CPU数据分析 2022-10-06
- 解决:apache24 安装后闪退和配置端口映射和连接超时设置 2023-09-11
- 【转载】CentOS安装Tomcat 2023-09-24
- CentOS_mini下安装docker 之 安装docker CE 2023-09-23
- IIS搭建ftp服务器的详细教程 2022-11-15
- 教你在docker 中搭建 PHP8 + Apache 环境的过程 2022-10-06
- KVM虚拟化Linux Bridge环境部署的方法步骤 2023-07-11
- CentOS7安装GlusterFS集群的全过程 2022-10-10