转载自:https://www.gxlsystem.com/qianduan-5102.html
第一步:创建服务文件 workerman.service(权限755)
目录:/lib/systemd/system/workerman.service
第二步:复制以下代码保存退出,注意修改你的workerman路径
路径:/www/wwwroot/xxx.com/server.php
启动命令:php server.php start
上面命令中能启动,路径就是下面这样子
[Unit]
Description=workerman
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/php /xxx/xxx/server.php start -d
ExecReload=/usr/bin/php /xxx/xxx/server.php restart
ExecStop=/usr/bin/php /xxx/xxx/server.php stop
PrivateTmp=true
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
修改这个文件,一定重启服务器,不然不生效的
第三步:启动服务
systemctl start workerman.service
第四步:查看服务状态
systemctl status workerman.service
第五步:开机启动
systemctl enable workerman.service
Tips: 禁用开机启动
systemctl disable workerman.service
错误:
The unit file, source configuration file or drop-ins of workerman.service changed on disk. Run 'systemctl daemon-reload' to reload units
修改了workerman.service服务文件没有重启服务器
标签:service,xxx,server,workerman,systemctl,自动,开机,php From: https://www.cnblogs.com/dengxiaobo/p/17082151.html