PHP8出了,今天又安装了下完整的LAMP环境;安装成功完成后,启动php-fpm服务时却出现了错误。
如下:
[root@nw-base php8]# systemctl restart php-fpm.service Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details. [root@nw-base php8]# journalctl -n -- Logs begin at Fri 2021-01-15 11:47:43 CST, end at Tue 2021-02-09 17:36:46 CST. -- Feb 09 17:10:04 nw-base systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG Feb 09 17:10:04 nw-base systemd[1]: php-fpm.service: Failed with result 'exit-code'. Feb 09 17:10:04 nw-base systemd[1]: Failed to start The PHP FastCGI Process Manager. Feb 09 17:36:46 nw-base systemd[1]: Starting The PHP FastCGI Process Manager... Feb 09 17:36:46 nw-base php-fpm[651926]: [09-Feb-2021 17:36:46] ERROR: failed to open error_log (/usr/local/php8/var/log/php-fpm.log): Read-only file system > Feb 09 17:36:46 nw-base php-fpm[651926]: [09-Feb-2021 17:36:46] ERROR: failed to post process the configuration Feb 09 17:36:46 nw-base php-fpm[651926]: [09-Feb-2021 17:36:46] ERROR: FPM initialization failed Feb 09 17:36:46 nw-base systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG Feb 09 17:36:46 nw-base systemd[1]: php-fpm.service: Failed with result 'exit-code'. Feb 09 17:36:46 nw-base systemd[1]: Failed to start The PHP FastCGI Process Manager.
经过一番查找,是由于从源码中复制出来新的php-fpm.service服务脚本里面添加了关于安全方面新的参数。
[root@nw-base php8]# vim /usr/lib/systemd/system/php-fpm.service
... # Mounts the /usr, /boot, and /etc directories read-only for processes invoked by this unit. ProtectSystem=full ...
配置写得清楚,启动的进程会将/usr, /boot, /etc 目录挂载为只读;我编译的php刚好安装在/usr/local,故没有权限操作。
知道原因后就有办法解决,可改为ProtectSystem=false;或改php-fpm配置文件,修改进程pid文件及日志文件的存放位置后重启即可。
[root@nw-base php8]# systemctl daemon-reload [root@nw-base php8]# systemctl restart php-fpm.service [root@nw-base php8]# systemctl status php-fpm.service ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2021-02-09 17:52:56 CST; 5s ago Main PID: 652064 (php-fpm) Status: "Ready to handle connections" Tasks: 3 (limit: 101152) Memory: 14.7M CGroup: /system.slice/php-fpm.service ├─652064 php-fpm: master process (/usr/local/php8/etc/php-fpm.conf) ├─652065 php-fpm: pool www └─652066 php-fpm: pool www Feb 09 17:52:56 nw-base systemd[1]: Starting The PHP FastCGI Process Manager... Feb 09 17:52:56 nw-base systemd[1]: Started The PHP FastCGI Process Manager. [root@nw-base php8]#
Wow, amazing blog structure! How lengthy have you been running a blog for?
you made blogging look easy. The full look of your web site is wonderful,
let alone the content!
你好,这个报错应该是使用systemctl启动服务时提示的,可以在.service服务文件中添加ProtectSystem=true试下。
It is very comforting to see that others are suffering from the same problem as you, wow!