NGINX systemd service file
[Unit] 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
Here is what the above code is Doing:
1. We’re creating a new file called nginx.service in the /etc/systemd/system directory.
2. We’re writing the contents of the file to the file.
3. We’re closing the file.
Now that we have our service file, we can start the service.
sudo systemctl start nginx
We can also enable the service so that it starts at boot:
sudo systemctl enable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable the service using the disable argument:
sudo systemctl disable nginx
We can check the status of the service using the status argument:
sudo systemctl status nginx
We can stop the service using the stop argument:
sudo systemctl stop nginx
We can restart the service using the restart argument:
sudo systemctl restart nginx
We can reload the service using the reload argument:
sudo systemctl reload nginx
We can disable