大家好,又见面了,我是你们的朋友全栈君。
wget http://nginx.org/download/nginx-1.22.0.tar.gz
tar -zxvf nginx-1.22.0.tar.gz
cd nginx-1.22.0
sudo groupadd nginx
sudo useradd nginx -g nginx -s /sbin/nologin -M
sudo ./configure --prefix=/usr/local/nginx \
--user=nginx --group=nginx \
--with-http_stub_status_module --with-http_ssl_module \
--with-http_realip_module --with-http_gzip_static_module \
--with-file-aio --with-http_realip_module
echo $?
sudo make -j4
echo $?
sudo make -j4 install
sudo /usr/local/nginx/sbin/nginx -v
sudo /usr/local/nginx/sbin/nginx -t
# 启动nginx
sudo /usr/local/nginx/sbin/nginx
# 重新载入配置文件
sudo /usr/local/nginx/sbin/nginx -s reload
# 快速关闭 Nginx
sudo /usr/local/nginx/sbin/nginx -s stop
# 关闭Nginx
sudo /usr/local/nginx/sbin/nginx -s quit
cd /usr/lib/systemd/system/
sudo vim nginx.service
[Unit]
Description=nginx
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPost=/bin/sleep 0.1
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 重新加载服务文件
sudo systemctl daemon-reload
sudo systemctl start|stop|reload|restart|status nginx.service
# 开机自启:
sudo systemctl enable nginx.service
# 关闭开机自启:
sudo systemctl disable nginx.service
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/185576.html原文链接:https://javaforall.cn