一:安装依赖
yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
二:下载Nginx版本
1.官网直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
2.使用wget命令下载
wget -c https://nginx.org/download/nginx-1.18.0.tar.gz
三:解压
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
四:配置
1.不需要SSL
./configure --prefix=/usr/local/nginx
2.需要SSL
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
五:编译安装
make
make install
六:启动Nginx
# 启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 重启
/usr/local/nginx/sbin/nginx -s reload