1.nginx在线yum安装
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl--devel
2.nginx在线下载
wget -c http://nginx.org/download/nginx-1.21.1.tar.gz
tar -zxvf nginx-1.21.1.tar.gz
3.根据需要增加modle
cd nginx-1.21.1 执行configure命令
sudo ./configure --prefix=/usr/local/nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module
如果报错误,再执行下面的命令 sudo yum -y install libxml2 libxml2-dev sudo yum -y install libxslt-devel sudo yum -y install perl-ExtUtils-Embed
4.nginx启动
cd /usr/local/nginx.sbin执行 ./nginx 命令
5.查看nginx是否启动成功
ps -ef|grep nginx
如图: