为了账号安全,请及时绑定邮箱和手机立即绑定

Webman框架实现在linux上开机自启动和服务管理

标签:
PHP 运维

php-webman高性能框架在linux上实现服务管理以及自启动配置

在linux搭建完项目以后,通过在【etc/systemd/system】目录编写【.service】文件来进行管理,添加完以后可以使用【systemct | status | restart | start | stop php-webman.service】命令来进行管理

第一步

在【etc/systemd/system】目录里面创建【php-webman.service】文件,文件内容如下:

[Unit]
Description=TPSP Exam Service

[Service]
# 使用哪个用户进行启动
User=apache
Group=apache
# 工作目录
WorkingDirectory=/data/app/tpsp-exam-service
# 环境变量,没有需要加载的环境变量可以不写这一行
EnvironmentFile=/data/app/tpsp.env
Type=forking
# 这里一定要写pid的文件位置,不然没法进行管理,实验多次了!!!
PIDFile=/data/app/tpsp-exam-service/tpsp-exam-service/runtime/webman.pid
# 启动时执行的命令:systemctl start php-webman.service
ExecStart=/data/app/tpsp-exam-service/tpsp-exam-service/start.php start -d
# 停止时执行的命令:systemctl stop php-webman.service
ExecStop=/data/app/tpsp-exam-service/tpsp-exam-service/start.php stop
Restart=on-failure
RestartSec=60

[Install]
WantedBy=multi-user.target

第二步:配置开机启动

重新加载systemd的守护进程配置

# 设置开机自启动
systemctl enable php-webman.service
# 使配置生效
systemctl daemon-reload

按照上面的步骤配置完以后,就可以通过【systemct | status | restart | start | stop php-webman.service】命令来管理webman服务了

点击查看更多内容
1人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消