1.环境准备:
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.上传文件并解压 或者通过wget下载文件
例如:
wget -c https://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
3.安装配置执行(自定义安装目录)
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_gzip_static_module --with-pcre
#–prefix 指定安装路径
#–with-http_stub_status_module 允许查看nginx状态的模块
#–with-http_ssl_module 支持https的模块
- make && make install
- 开机脚本制作
- 5.1目录·/usr/lib/systemd/system
- vim nginx.service
#!/bin/sh [Unit] Description=nginx service After=network.target [Service] Type=forking PIDFile=/usr/local/software/nginx/logs/nginx.pid ExecStart=/usr/local/software/nginx/sbin/nginx ExecReload=/usr/local/software/nginx/sbin/nginx -s reload ExecStop=/usr/local/software/nginx/sbin/nginx -s stop PrivateTmp=true [Install] WantedBy=multi-user.target
- chmod 777 nginx.service
- systemctl daemon-reload
- systemctl enable nginx.service



