二进制安装1.14.2和1.20.1NGINX
nginx-1.14.2
yum -y install gcc automake autoconf libtool make pcre pcre-devel zlib zlib-devel openssl openssl-devel wget http://nginx.org/download/nginx-1.14.2.tar.gz tar xf nginx-1.14.2.tar.gz -C /opt/ cd /opt/nginx-1.14.2/ useradd -u 601 nginx -s /sbin/nologin -M sed -i 's@1.14.2@1.0.0@g' ./src/core/nginx.h sed -i 's@"nginx/"@"apache/"@g' ./src/core/nginx.h sed -i '22s@"NGINX"@"APACHE"@g' ./src/core/nginx.h sed -i '49s#nginx#apache#g' ./src/http/ngx_http_header_filter_module.c sed -i '36s#nginx#apache#gp' ./src/http/ngx_http_special_response.c ./configure --prefix=/home/app/nginx --sbin-path=/home/app/nginx/sbin/nginx --conf-path=/home/app/nginx/conf/nginx.conf --error-log-path=/home/log/nginx/error.log --http-log-path=/home/log/nginx/access.log --pid-path=/run/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_v2_module --with-stream --with-http_gzip_static_module make && make install cp -a /home/app/nginx/sbin/nginx /usr/local/bin/ firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload #使用systemctl管理nginx cat <<efo> /usr/lib/systemd/system/nginx.service [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/run/nginx.pid # Nginx will fail to start if /run/nginx.pid already exists but has the wrong # SELinux context. This might happen when running `nginx -t` from the cmdline. # https://bugzilla.redhat.com/show_bug.cgi?id=1268621 ExecStartPre=/usr/bin/rm -f /run/nginx.pid ExecStartPre=/home/app/nginx/sbin/nginx -t ExecStart=/home/app/nginx/sbin/nginx ExecReload=/bin/kill -s HUP $MAINPID KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true LimitCORE=infinity LimitNOFILE=10240 LimitNPROC=10240 [Install] WantedBy=multi-user.target efo
nginx-1.20.1
yum -y install gcc automake autoconf libtool make pcre pcre-devel zlib zlib-devel openssl openssl-devel wget http://nginx.org/download/nginx-1.20.1.tar.gz tar xf nginx-1.20.1.tar.gz -C /opt/ cd /opt/nginx-1.20.1/ useradd -u 601 nginx -s /sbin/nologin -M sed -i 's@1.20.1@1.0.0@g' ./src/core/nginx.h sed -i 's@"nginx/"@"apache/"@g' ./src/core/nginx.h sed -i '22s@"NGINX"@"APACHE"@g' ./src/core/nginx.h sed -i '49s#nginx#apache#g' ./src/http/ngx_http_header_filter_module.c ./configure --prefix=/home/app/nginx --sbin-path=/home/app/nginx/sbin/nginx --conf-path=/home/app/nginx/conf/nginx.conf --error-log-path=/home/log/nginx/error.log --http-log-path=/home/log/nginx/access.log --pid-path=/run/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_v2_module --with-stream --with-http_gzip_static_module make && make install cp -a /home/app/nginx/sbin/nginx /usr/local/bin/ firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload #使用systemctl管理nginx cat <<efo> /usr/lib/systemd/system/nginx.service [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/run/nginx.pid # Nginx will fail to start if /run/nginx.pid already exists but has the wrong # SELinux context. This might happen when running `nginx -t` from the cmdline. # https://bugzilla.redhat.com/show_bug.cgi?id=1268621 ExecStartPre=/usr/bin/rm -f /run/nginx.pid ExecStartPre=/home/app/nginx/sbin/nginx -t ExecStart=/home/app/nginx/sbin/nginx ExecReload=/bin/kill -s HUP $MAINPID KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true LimitCORE=infinity LimitNOFILE=10240 LimitNPROC=10240 [Install] WantedBy=multi-user.target efo
ln /home/app/nginx/sbin/nginx /usr/sbin/nginx
nginx -V