Add a custom service using systemctl

Add nginx.service to the /usr/lib/systemd/system directory

nginx.service

[Unit]
Description=nginx 
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/serve/nginx/sbin/nginx
ExecReload=/serve/nginx/sbin/nginx -s reload
ExecStop=/serve/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Copy the code

Common commands

Service: systemctl start nginx.service: systemctl start nginx.service Service: systemctl reload nginx.serviceCopy the code