天天看點

PHP腳本調用systemctl,systemctl start php-fpm.service錯誤,systemctl enable php-fpm.service錯誤...

背景:源碼安裝了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