yum install openssl-devel pcre-devel gcc -y
wget -O /opt/nginx-1.18.0.tar.gz http://nginx.org/download/nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz
groupadd www -g 2000
useradd www -s /sbin/nologin -M -u 2000 -g 2000
cd /opt/nginx-1.18.0
./configure --help#查看配置帮助
./configure --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
make && make install
/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
#绝对命令启动的nginx也可以把nginx放到/usr/sbin里
cp /opt/nginx/sbin/nginx /usr/sbin/nginx
/opt/nginx/sbin/nginx -s stop
/opt/nginx/sbin/nginx -s reload
cat > /usr/lib/systemd/system/nginx.service << ‘EOF‘
[Unit]
Description=Hello Nginx
[Service]
Type=forking
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecStop=/opt/nginx/sbin/nginx -s stop
ExecReload=/opt/nginx/sbin/nginx -s reload
[Install]
WantedBy=multi-user.target
EOF
systemctl start nginx
ps aux|grep nginx
systemctl stop nginx
ps aux|grep nginx
systemctl reload nginx
ps aux|grep nginx
原文:https://www.cnblogs.com/jinglobal/p/14632559.html