大家好,本来希望把生产环境的服务器升级到CENTOS8的,但后来看到CENTOS8已经停止维护了,虽然各大云上支持选择CENTOS8,但实际在安装服务时找不到各种依赖包,实在太无语了,这就是开源的悲催,哈哈,最后退而求期次选择了CENTOS7的最新版CENTOS7.9,费话不多説,开始安装NGINX最新稳定版
一、下载nginx:
Stable version http://nginx.org/download/nginx-1.20.2.tar.gz
cd /usr/local/src/
dnf install pcre-devel openssl openssl-devel
git clone https://github.com/vozlt/nginx-module-vts.git
wget http://nginx.org/download/nginx-1.20.2.tar.gz
tar zxvf nginx-1.20.2.tar.gz
cd nginx-1.20.2
./configure --prefix=/usr/local/Kaiyuan/nginx --conf-path=/usr/local/Kaiyuan/nginx/conf/nginx.conf --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log --user=www --group=www --http-client-body-temp-path=/usr/local/Kaiyuan/nginx/tmp/client_body --http-proxy-temp-path=/usr/local/Kaiyuan/nginx/tmp/proxy --http-fastcgi-temp-path=/usr/local/Kaiyuan/nginx/tmp/fastcgi --without-http_uwsgi_module --without-http_scgi_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-cc-opt='-O2 -g' --add-module=../nginx-module-vts --with-http_v2_module
make
make install
groupadd -g 1000 www
useradd -s /sbin/nologin -u 1000 -g www www
mkdir -p /usr/local/Kaiyuan/nginx/tmp/client_body
chown -R www.www /usr/local/Kaiyuan/nginx/tmp
mkdir /usr/local/Kaiyuan/nginx/var
chown -R www.www /usr/local/Kaiyuan/nginx/var
生了service文件
vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/Kaiyuan/nginx/sbin/nginx
ExecReload=/usr/local/Kaiyuan/nginx/sbin/nginx -s reload
ExecStop=/usr/local/Kaiyuan/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重启
systemctl daemon-reload
systemctl enable nginx
systemctl start nginx