安装

yum install python-setuptools
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf

或者使用如下命令安装

yum install -y epel-release
yum install -y supervisor

编辑配置

vi /etc/supervisord.conf

加入下列配置:

[supervisorctl]
; 任务名称test
[program:test]
; 执行的用户
user = www
; 是否自动启动
autostart = true
; 是否自动重启
autorestart = true
; 启动时间
startsecs = 10
; 错误日志地址
stderr_logfile = /var/log/test_err.log
stdout_logfile = /var/log/test.log
; 执行的shell命令
command = php /var/www/html/test/index.php

保存退出,启动任务管理器

supervisord -c /etc/supervisord.conf

重新载入配置

supervisorctl reload

进入任务管理

supervisorctl
supervisor> start test
supervisor> stop test
supervisor> restart test