ubuntu環境下啟動php-fpm失敗Job for php-fpm.service failed...

騎著程式碼去流浪發表於2018-05-29
root@4fun:~# service php-fpm start
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@4fun:~# systemctl status php-fpm.service
● php-fpm.service - LSB: starts php-fpm
   Loaded: loaded (/etc/init.d/php-fpm; bad; vendor preset: enabled)
  Drop-In: /etc/systemd/system/php-fpm.service.d
           └─override.conf
   Active: failed (Result: exit-code) since Thu 2018-05-17 17:14:02 CST; 5min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 27858 ExecStop=/etc/init.d/php-fpm stop (code=exited, status=0/SUCCESS)
  Process: 28308 ExecStart=/etc/init.d/php-fpm start (code=exited, status=1/FAILURE)

May 17 17:14:02 xcys systemd[1]: Starting LSB: starts php-fpm...
May 17 17:14:02 xcys php-fpm[28308]: Starting php-fpm [17-May-2018 17:14:02] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr
May 17 17:14:02 xcys php-fpm[28308]: [17-May-2018 17:14:02] ERROR: No pool defined. at least one pool section must be specified in config file
May 17 17:14:02 xcys php-fpm[28308]: [17-May-2018 17:14:02] ERROR: failed to post process the configuration
May 17 17:14:02 xcys php-fpm[28308]: [17-May-2018 17:14:02] ERROR: FPM initialization failed
May 17 17:14:02 xcys php-fpm[28308]:  failed
May 17 17:14:02 xcys systemd[1]: php-fpm.service: Control process exited, code=exited status=1
May 17 17:14:02 xcys systemd[1]: Failed to start LSB: starts php-fpm.
May 17 17:14:02 xcys systemd[1]: php-fpm.service: Unit entered failed state.
May 17 17:14:02 xcys systemd[1]: php-fpm.service: Failed with result 'exit-code'.

原因是在/usr/local/php/etc/php-fpm.d目錄下缺少對應的.conf配置檔案

安裝php-fpm時候系統會自動生成一個預設的配置檔案,進入php-fpm.d資料夾可以看到:

root@4fun:~# cat /usr/local/php/etc/php-fpm.d/www.conf.default 
.bash_history     .cache/           .my.cnf           .profile          .vim/             lnmp-install.log  
.bashrc           .composer/        .pearrc           .ssh/             .viminfo          lnmp1.4/          
root@4fun:~# cat /usr/local/php/etc/php-fpm.d/www.conf.default 
.bash_history     .cache/           .my.cnf           .profile          .vim/             lnmp-install.log  
.bashrc           .composer/        .pearrc           .ssh/             .viminfo          lnmp1.4/          
root@4fun:~# cat /usr/local/php/etc/php-fpm.d/www.conf.default 
.bash_history     .cache/           .my.cnf           .profile          .vim/             lnmp-install.log  
.bashrc           .composer/        .pearrc           .ssh/             .viminfo          lnmp1.4/          
root@4fun:~# cd /usr/local/php/etc/php-fpm.d/
root@4fun:/usr/local/php/etc/php-fpm.d# ls
www.conf.default

將該檔案複製一份重新命名問*.conf名稱,重新啟動php-fpm即可

root@4fun:/usr/local/php/etc/php-fpm.d# cp www.conf.default www.conf
root@4fun:/usr/local/php/etc/php-fpm.d# ls
www.conf  www.conf.default

root@4fun:/usr/local/php/etc/php-fpm.d# service php-fpm start

相關文章