PHP脚本调用systemctl,systemctl start php-fpm.service错误,systemctl enable php-fpm.service错误...

黄俊智
2023-12-01

背景:源码安装了php7,进入sbin目录“./php-fpm”启动php正常,但如下添加自启动等操作则失败,求解啊

1.安装完后添加启动配置文件php-fpm.service,并编辑vi /usr/lib/systemd/system/php-fpm.service,内容输入

[Unit]Description=The PHP FastCGI Process Manager

After=network.target

[Service]Type=simple

PIDFile=/lnmp/soft/php/var/run/php-fpm.pid

ExecStart=/lnmp/soft/php/sbin/php-fpm --nodaemonize --fpm-config /lnmp/soft/php/etc/php-fpm.conf

ExecReload=/bin/kill -USR2 $MAINPID

PrivateTmp=true

[Install]WantedBy=multi-user.target

2.使用systemctl start php-fpm启动,提示

Failed to start php-fpm.service: Unit is not loaded properly: Bad message.See system logs and 'systemctl status php-fpm.service' for details.

执行命令systemctl status php-fpm.service,显示多条如下错误信息

** [/usr/lib/systemd/system/php-fpm.service:1] Invalid section header '[Unit]Description=The PHP FastCGI Process Manager'**

3.使用systemctl enable php-fpm.service,提示Failed to execute operation: Bad message

 类似资料: