以 nginx 为例
1. 保存文件到 /lib/systemd/system/nginx.service。
2. 文件内容:[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3. 设置开机启动systemctl enable nginx.service
php 环境包启动参考:
1,下载地址:
2, servicesudo vi /usr/lib/systemd/system/websrv.service[Unit]
Description=websrv
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/srv/websrv/config/start_websrv.sh
ExecReload=/srv/websrv/config/reload_websrv.sh
ExecStop=/srv/websrv/config/stop_websrv.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target