继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

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

知小帆
关注TA
已关注
手记 49
粉丝 19
获赞 138

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服务了

打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP