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

转自--https://www.cnblogs.com/onephp/p/6093707.html

1、添加服务

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

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

[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

 

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指令
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
posted @ 2020-07-23 10:28  Neige  阅读(788)  评论(0编辑  收藏  举报