一、安装包下载

下载地址:http://nginx.org/
其他安装包:
pcre-8.37.tar.gz(http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
nginx-1.20.1.tar.gz (http://nginx.org/download/nginx-1.20.1.tar.gz

安装参考:https://cloud.tencent.com/developer/article/1619507

二、安装nginx

1. 安装pcre(或yum安装)

[root@hadoop103 ~]# yum install gcc-c++
[root@hadoop103 ~]# cd /opt/software/
[root@hadoop103 software]# tar -zxvf pcre-8.37.tar.gz
[root@hadoop103 software]# cd pcre-8.37
[root@hadoop103 pcre-8.37]# ./configure
[root@hadoop103 pcre-8.37]# make
[root@hadoop103 pcre-8.37]# make install

2. 安装openssl、zlib

[root@hadoop103 pcre]# yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

3. 安装nginx

[root@hadoop103 pcre-8.37]# groupadd nginx
[root@hadoop103 pcre-8.37]# useradd nginx -g nginx -s /sbin/nologin -M
[root@hadoop103 pcre-8.37]# mkdir /usr/local/nginx && mkdir /var/log/nginx && mkdir /var/cache/nginx
[root@hadoop103 pcre-8.37]# cd /opt/software
[root@hadoop103 software]# tar -zxvf nginx-1.17.0.tar.gz
[root@hadoop103 software]# cd nginx-1.17.0
[root@hadoop103 nginx-1.17.0]# ./configure

  1. ./configure \
  2. --prefix=/usr/local/nginx \
  3. --error-log-path=/var/log/nginx/error.log \
  4. --http-log-path=/var/log/nginx/access.log \
  5. --pid-path=/var/run/nginx.pid \
  6. --lock-path=/var/run/nginx.lock \
  7. --http-client-body-temp-path=/var/cache/nginx/client_temp \
  8. --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
  9. --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
  10. --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
  11. --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
  12. --user=nginx \
  13. --group=nginx \
  14. --with-file-aio \
  15. --with-threads \
  16. --with-http_addition_module \
  17. --with-http_auth_request_module \
  18. --with-http_dav_module \
  19. --with-http_flv_module \
  20. --with-http_gunzip_module \
  21. --with-http_gzip_static_module \
  22. --with-http_mp4_module \
  23. --with-http_random_index_module \
  24. --with-http_realip_module \
  25. --with-http_secure_link_module \
  26. --with-http_slice_module \
  27. --with-http_ssl_module \
  28. --with-http_stub_status_module \
  29. --with-http_sub_module \
  30. --with-http_v2_module \
  31. --with-mail \
  32. --with-mail_ssl_module \
  33. --with-stream \
  34. --with-stream_realip_module \
  35. --with-stream_ssl_module \
  36. --with-stream_ssl_preread_module

[root@hadoop103 nginx-1.17.0]# make && make install

4. 启停nginx

[root@hadoop103 nginx-1.17.0]# cd /usr/local/nginx/sbin
[root@hadoop103 sbin]# ./nginx (启动nginx)

[root@hadoop103 sbin]# ./nginx -s stop (关闭nginx)
[root@hadoop103 sbin]# ./nginx -s reload (修改配置文件后,重新加载,即无需重启服务)