简介:
php-fpm安装完成后默认不会注册为系统服务,所以需要手工添加系统服务脚本。在/etc/init.d目录下新建php-fpm文件,并更改权限其即可。
1、检测/usr/local/php/var/run/php-fpm.pid是否存在
1.1、不存在:去除/usr/local/php/etc/php-fpm.conf
里的“;pid = run/php-fpm.pid”前面的分号,并重启php-fpm就会自动生成php-fpm.pid
1.2、如何重启php-fpm(当然重启系统也是可以的)
1.2.1、查看php-fpm当前的进程ps -ef | grep php-fpm
1.2.2、结束php-fpm所有进程即可 例:kill -9 1228
1.2.3、启动php-fpm:/usr/local/php/sbin/php-fpm
2、新建php-fpm文件
2.1、新建文件:vi /etc/init.d/php-fpm
2.2、添加内容如下
#! /bin/sh # Comments to support chkconfig on CentOS # chkconfig: 2345 65 37 # set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="php-fpm daemon" NAME=php-fpm DAEMON=/usr/local/php/sbin/$NAME CONFIGFILE=/usr/local/php/etc/php-fpm.conf PIDFILE=/usr/local/php/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 d_start() { $DAEMON -y $CONFIGFILE || echo -n " already running" } d_stop() { kill -QUIT `cat $PIDFILE` || echo -n " not running" } d_reload() { kill -HUP `cat $PIDFILE` || echo -n " can't reload" } case "$1" in start) echo -n "Starting $DESC is success" d_start echo "." ;; stop) echo -n "Stopping $DESC is success" d_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." d_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC is success" d_stop sleep 1 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac
3、修改其权限并开机启动
3.1、修改权限:chmod 755 /etc/init.d/php-fpm
3.2、开机启动:chkconfig php-fpm on
3.3、查看开机启动的服务:chkconfig –list
4、备注
4.1、启动服务:service php-fpm start
4.2、停止服务:service php-fpm stop
4.3、重启服务:service php-fpm reload
博客参考:https://blog.csdn.net/baidu_37895884/article/details/78218453
评论前必须登录!
注册