php-fpm自启,Centos7设置php-fpm开机自启-转载

1、添加服务

vim /etc/systemd/system/php-fpm.service

内容如下(pid,php-fpm,conf路径按照自己的来适当更改,实在找不到可以用find / -name php-fpm.pid 查找)

48304ba5e6f9fe08f3fa1abda7d326ab.png

[Unit]

Description=The PHP FastCGI Process Manager

After=syslog.target network.target

[Service]

Type=simple

PIDFile=/run/php-fpm.pid

ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=/bin/kill -SIGINT $MAINPID

[Install]

WantedBy=multi-user.target

48304ba5e6f9fe08f3fa1abda7d326ab.png

2、启动php-fpm

systemctl start php-fpm.service

3、添加到开机启动(Failed to execute operation: File exists报错可以用:systemctl disable php-fpm.service 命令清除掉)

systemctl enable php-fpm.service

4、systemctl指令

48304ba5e6f9fe08f3fa1abda7d326ab.png

systemctl enable *.service #开机运行服务

systemctl disable *.service #取消开机运行

systemctl start *.service #启动服务

systemctl stop *.service #停止服务

systemctl restart *.service #重启服务

systemctl reload *.service #重新加载服务配置文件

systemctl status *.service #查询服务运行状态

systemctl --failed #显示启动失败的服务

修改 php.ini 文件 设置 expose_php = Off

vim /usr/local/php7/etc/php.ini

找到 expose_php = On

改为 expose_php = Off

来源:https://www.cnblogs.com/NeigeBolg/p/13364843.html

你可能感兴趣的:(php-fpm自启)