为了更高效的运维工作,写了下面关于nginx源码编译之后,配置systemctl开机自启动的脚本,其他源码编译类似的应用服务也可以使用下面脚本,需要更改对应的信息。
[[email protected] ~]# find / -name nginx.pid /usr/local/openresty/nginx/logs/nginx.pid [[email protected] system]# pwd /etc/systemd/system [[email protected] system]# cat nginx.service [Unit] Description=nginx web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/openresty/nginx/logs/nginx.pid ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -c /usr/local/openresty/nginx/conf/nginx.conf ExecStart=/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target [[email protected] system]#
原文链接