1、关闭防火墙
systemctl disable firewalld.service
2、上传压缩包并解压到目标文件
cd /usr/local
tar -zxvf nginx-1.22.0.tar.gz
3、安装Nginx相关依赖
yum install -y gcc-c++ zlib zlib-developenssl openssl-devel pcre pcre-devel
4、安装完毕后,进入nginx目录,并执行配置脚本
cd /usr/local/nginx-1.22.0./configure
5、编译安装
make & make install
6、设置Nginx开机自启动
vim /etc/rc.local在文本末尾添加:
/usr/local/nginx/sbin/nginx
7.启动Nginx
/usr/local/nginx/sbin/nginx
8、查询nginx是否启动
ps -ef | grep nginx