#!/bin/bash
#安装nginx需要的依赖,可以自己加。
yum install -y wget gzip tar make gcc
yum install -y pcre pcre-devel zlib-devel
yum install -y gcc-c++ openssl openssl-devel zlib-devel
#下载安装nginx源码包并解压,目录根据自己要求。
cd /wf
wget -c http://nginx.org/download/nginx-1.12.0.tar.gz
tar -xzf nginx-1.12.0.tar.gz
cd nginx-1.12.0
#修改nginx版本信息
sed -i -e 's/1.12.0//g' -e 's/nginx\//JWS/g' -e 's/"NGINX"/"JWS"/g' src/core/nginx.h
#创建www用户并编译nginx,参数按需求自己添加或删除
useradd www ;./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
#测试nginx启动文件正确性
/usr/local/nginx/sbin/nginx -t
#启动nginx
/usr/local/nginx/sbin/nginx
#查看nginx进程、端口、关闭防火墙
ps -ef|grep nginx
netstat -tnlp |grep 80
setenforce 0
systemctl stop firewalld.service
=========================================================================-====
分享来自思腾合力包头市云计算运维部
致力于高算力GPU服务器租赁/出售
vx:wf1109281561
自动化源码安装nginx脚本
于 2022-02-24 09:41:44 首次发布