centos7下php-fpm多实例运行开机自启动配置

在centos7中,/etc/rc.d/rc.local文件的权限被降低了,没有执行权限,需要给它添加可执行权限。

chmod +x /etc/rc.d/rc.local

然后就可以在里面添加你要开机自启的命令了

vi /etc/rc.d/rc.local

承接上篇文单的配置文件 www.conf,www1.conf,www2.conf添加php-fpm执行命令如下:

/usr/sbin/php-fpm --fpm-config /etc/php-fpm.d/www.conf

/usr/sbin/php-fpm --fpm-config /etc/php-fpm.d/www1.conf

/usr/sbin/php-fpm --fpm-config /etc/php-fpm.d/www2.conf

如下 图:

centos7下php-fpm多实例运行开机自启动配置

配置完成 ,重启服务器:reboot,然后通过命令ps -ef|grep php-fpm 查看 进程 ,这时可以看到有三个php-fpm 进程开启。配置成功.

查看rc.local运行状态 。

systemctl status rc-local

查看日志发现rc.local启动失败,绑定9002端口没有权限,关闭selinux即可如下:


[[email protected] ~]# cat /etc/sysconfig/selinux    

 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
#SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

将selinux=enforcing 改disabled。重启服务器