为了更高效的运维工作,写了下面关于nginx源码编译之后,配置systemctl开机自启动的脚本,其他源码编译类似的应用服务也可以使用下面脚本,需要更改对应的信息。
[root@leoheng ~]# find / -name nginx.pid
/usr/local/openresty/nginx/logs/nginx.pid
[root@leoheng system]# pwd
/etc/systemd/system
[root@leoheng 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
[root@leoheng system]#