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

本文详细介绍了如何在Linux环境下配置PHP-FPM服务,包括创建systemd服务单元文件、启动服务及将其设置为开机启动等步骤,并提供了禁用PHP暴露版本信息的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值