您的位置:首页 > 运维架构 > Linux

在centos7下使用systemctl加入自建服务

2017-12-14 18:22 676 查看
以nginx为例子

               1  在/usr/lib/systemd/system/  建立nginx.service文件    命令: touch  /usr/lib/systemd/system/nginx.service

               2  修改该文件   加入内容

             [Unit]

             Description=nginx - high performance web server 

             Documentation=http://nginx.org/en/docs/

             After=network.target remote-fs.target nss-lookup.target

           [Service]

           Type=forking

           PATH=/usr/local/nginx

           NAME=nginx

           PIDFile=$PATH/logs/$NAME

           ExecStartPre=$PATH/sbin/nginx -t -c $PATH/conf/nginx.conf

           ExecStart=$PATH/sbin/nginx -c $PATH/conf/nginx.conf

           ExecReload=/bin/kill -s HUP $MAINPID

           ExecStop=/bin/kill -s QUIT $MAINPID

           PrivateTmp=true

           [Install]

           WantedBy=multi-user.target

            3  保存后重启机器

            4 加入开机自启   systemctl enable nginx.service
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: