What's the problem with this nginx unit file? systemctl stop nginx isn't working

Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

In case the $MAINPID does not work, try

ExecStop=/usr/sbin/nginx -s quit
1 Like

The stop that works for me is:

ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.