以nginx为例:
假设已经编译安装nginx服务,并将启动脚本存放在/etc/init.d下,以nginx为名,并修改为可执行权限。
[[email protected] ~]# cd /lib/systemd/system/
[[email protected] system]# vim nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/nginx start
ExecReload=/etc/init.d/nginx restart
ExecStop=/etc/init.d/nginx stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[[email protected]]# systemctl enable nginx.service
[[email protected] system]# systemctl start nginx.service
[[email protected] system]# netstat -lntp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 15136/nginx: master
时间: 2024-10-19 20:27:05