一、安装编译环境
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
二、下载nginx安装包
(1)本地上传
官网下载tar包:https://nginx.org/en/download.html
(2)在线下载
wgte https://nginx.org/download/nginx-1.24.0.tar.gz
三、开始安装
tar xvf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
# 查看安装路径
whereis nginx
# 拷贝nginx运行命令,快捷运行
cp /usr/local/nginx/sbin/nginx /usr/local/bin/
# 查看nginx版本
nginx -V
# 启动nginx
nginx
# 测试访问是否运行ok
curl http://localhost
# 关闭nginx
nginx -s stop
# 重启nginx
nginx -s reload
# 检查nginx配置文件
nginx -t