在php-fpm还是打补丁的时候,php-fpm重启只需要执行php-fpm restart或者reload, 自从php5.3之后,php-fpm的启动和停止显得比较麻烦,特意改写了一份nginx的自启动脚本,如下脚本phpfpm="/usr/local/php-5.3.10/sbin/php-fpm" 修改为你的php-fpm就可以了。
php-fpm自启动脚本
1
|
cat /etc/init.d/nginx
|
内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/sh
# DateTime: 2013-09-16
# Author: lianbaikai
# site:http://www.ttlsa.com/html/3039.html
# chkconfig: - 84 16
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
phpfpm="/usr/local/php-5.3.10/sbin/php-fpm"
prog=$(basename ${phpfpm})
lockfile=/var/lock/subsys/phpfpm
start() {
[ -x ${phpfpm} ] || exit 5
echo -n $"Starting $prog: "
daemon ${phpfpm}
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc ${phpfpm} -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
${phpfpm} -t
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|configtest}"
exit 2
esac
|
配置php-fpm服务
1
2
3
4
5
6
7
|
# php-fpm加入服务
chkconfig --add php-fpm
# php-fpm 234级别下设置为启动
chkconfig php-fpm on
# 查看php-fpm服务当前配置
chkconfig --list php-fpm
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
php-fpm使用方法
1
2
3
4
5
6
7
8
9
10
|
# 启动
service php-fpm start
# 关闭
service php-fpm stop
# 重启
service php-fpm restart
# 重载
service php-fpm reload
#检查配置文件
service php-fpm configtest
|