以nginx为例:
假设已经编译安装nginx服务,并将启动脚本存放在/etc/init.d下,以nginx为名,并修改为可执行权限。
[root@yum ~]# cd /lib/systemd/system/
[root@yum 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
[root@yumsystem]# systemctl enable nginx.service
[root@yum system]# systemctl start nginx.service
[root@yum system]# netstat -lntp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 15136/nginx: master
本文出自 “黑夜路人” 博客,请务必保留此出处http://kevinhao.blog.51cto.com/5204735/1718596
原文地址:http://kevinhao.blog.51cto.com/5204735/1718596