下载
wget http://nginx.org/download/nginx-1.17.7.tar.gz
详细配置地址:http://nginx.org/en/docs/configure.html
tar -zxvf nginx-1.17.7.tar.gz
cd nginx-1.17.7.tar.gz
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/usr/local/nginx/logs/nginx.pid
make && make install
将nginx添加到systemctl 添加位置/usr/lib/systemd/system/nginx.service
[Unit]
Description=Nginx Server
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
添加完成后执行 systemctl daemon-reload 重新加载就可以使用了