脚本
#!/bin/bash
# 新建用户 - - -不允许用户登录
id wp || useradd wp -s /sbin/nologin
# 新建nginx目录
mkdir /nginx -p
cd /nginx
# 解决依赖关系
yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc gcc-c++ autoconf automake make -y
# download nginx
curl -O http://nginx.org/download/nginx-1.19.9.tar.gz
# 解压nginx安装包
tar -xf nginx-1.19.9.tar.gz
cd nginx-1.19.9
# 生成编译前配置工作
./configure --prefix=/usr/local/nginx --user=wp --group=wp --with-threads --with-http_ssl_module --with-http_realip_module --with-http_v2_module --with-file-aio --with-http_stub_status_module --with-stream
# 编译 --- -j 2 表示用两个进程进行编译
make -j 2
# 编译安装
make install
#启动nginx
/usr/local/nginx/sbin/nginx
#修改PATH变量
echo "PATH=$PATH:/usr/local/nginx/sbin" >>/root/.bashrc
#执行修改了环境变量的脚本
source /root/.bashrc
echo "PATH=$PATH:/usr/local/nginx/sbin"
>>/etc/profile
source /etc/profile
#关闭firewalld和selinux
#stop firewall和设置下次开机不启动firewalld
service firewalld stop
systemctl disable firewalld
#临时停止selinux和永久停止selinux
setenforce 0
sed -i '/^SELINUX=/ s/enforcing/disabled/' /etc/selinux/config
模块
--prefix=/usr/local/nginx1
指定启动nginx的进程用户
--user=wp
指定启动的组
--group=wp
启用线程池的使用
--with-threads
启用构建将HTTPS协议支持添加
--with-http_ssl_module
将客户端地址更改为在指定的标头字段中发送的地址
--with-http_realip_module
支持构建提供对HTTP/2支持的模块
--with-http_v2_module
在FreeBSD和linux上使用异步文件I/O
--with-file-aio
该模块提供对基本状态信息的访问
--with-http_stub_status_module
构建通用TCP/UDP代理和负载均衡的流模块 - - -四层负载均衡的支持
--with-stream