Vesta: php-fpm fails to restart from VestaCP

Created on 27 Sep 2017  路  13Comments  路  Source: serghey-rodin/vesta

Operating System (OS/VERSION):

Ubuntu 16.04

VestaCP Version:

R17

Installed Software (what you got with the installer):

php-fpm, nginx, mysql, php7.0

Steps to Reproduce:

https:/my.ip.address/8083/edit/server/php-fpm > Save (and restart PHP-FPM)

Related Issues/Forum Threads:

1025 #1042

Other Notes:

Error: php-fpm7.0 failed to start with new config

Anything else?

https://github.com/serghey-rodin/vesta/commit/76d518bf864fd6e53a36253c12d8e78d9c61a7a7

There are two php*-fpm scripts in /etc/init.d/, so it is unable to restart from the GUI.

Solved

Most helpful comment

@klou , You should just specify name of the service which controls php-fpm process in _/usr/local/vesta/bin/v-change-sys-service-config_ script at 98th row, not binary filename.
For example, replace php-fpm7.1 (or more complicated statement, like =$(ls /usr/sbin/php*fpm* |cut -f 4 -d /) ) with just php-fpm And it works well for me.
My excerpt from the script mentioned above

 if [ "$service" = 'php' ]; then
      if [ "$WEB_SYSTEM" = "nginx" ]; then
            service="php-fpm"
       else
            service=$WEB_SYSTEM
       fi
 fi

For Ubuntu 16.04

All 13 comments

Having the same issue, with the same installation

Wonder if this would work better for people who have multiple php*-fpm on their system?

# restart any *running* php fpm found with ps uaxw
# otherwise, simply use: 
# find /etc/init.d/ -name 'php*-fpm*' -type f -exec basename {} \; | xargs -I{} service {} restart || true
phpfpms="5.6:7.0:7.1:7.2:8.0"
set -f                      # avoid globbing (expansion of *).
iphpfpm=(${phpfpms//:/ })
for i in "${!iphpfpm[@]}"
do
  if ps auxw | grep php/${iphpfpm[i]}/fpm | grep -v grep > /dev/null
  then
    service php${iphpfpm[i]}-fpm restart || true
  fi
done

@klou , You should just specify name of the service which controls php-fpm process in _/usr/local/vesta/bin/v-change-sys-service-config_ script at 98th row, not binary filename.
For example, replace php-fpm7.1 (or more complicated statement, like =$(ls /usr/sbin/php*fpm* |cut -f 4 -d /) ) with just php-fpm And it works well for me.
My excerpt from the script mentioned above

 if [ "$service" = 'php' ]; then
      if [ "$WEB_SYSTEM" = "nginx" ]; then
            service="php-fpm"
       else
            service=$WEB_SYSTEM
       fi
 fi

For Ubuntu 16.04

I've started getting the same error on my server when adding a new domain. I get the error as a popup, but then when I press "add" again, it works! As far as I can see it seems to restart the 2nd time around. Not sure if it's related? (I never used to get that error come up when adding a new domain)

I've started getting the same error on my server when adding a new domain. I get the error as a popup, but then when I press "add" again, it works! As far as I can see it seems to restart the 2nd time around. Not sure if it's related? (I never used to get that error come up when adding a new domain)

i have same problem

I've started getting the same error on my server when adding a new domain. I get the error as a popup, but then when I press "add" again, it works! As far as I can see it seems to restart the 2nd time around. Not sure if it's related? (I never used to get that error come up when adding a new domain)

i have same problem

I also have the same issues

Workaround, which Pleskan suggested worked forked for me on Ubuntu 16.04.3
The thing is when I run
/etc/init.d/php7.0-fpm status
it shows that service is dead

Everything is ok, when I run
/etc/init.d/php-fpm status

I believe this work the best:

https://github.com/serghey-rodin/vesta/pull/1811/files/ce6084746407e024bd7365b138c2dddfb1e99020

In case systemd is present (php-fpm is then not in /etc/init.d/) it'll find the service(s) name.
In case they are multiple php-fpms present (per @dpeca suggestion), it'll restart each of them.

I urge maintainers to review and accept my FIX as this is annoying, having fixes, not having anyone to review/contribute and push them.
@serghey-rodin

Already fixed. Can't reproduce on Ubuntu 16.04 with php 7.0

@anton-reutov This bug may be fixed on ubuntu, but is still present on CentOS 7.X versions
reopen the issue.

I installed vestacp today. I am having this issue with Ubuntu 18.04 version as well with the nginx + php-fpm +mysql config....

For those still having this problem.

When i upgrade my php from 7.2 to 7.4 in Ubuntu 18.04LTS i had this issue from time to time of Error: php-fpm restart failed when adding a new domain. When i did the second one it worked. I decided to dig the content of /etc/init.d/php-fpm and found this:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          php7.2-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php7.2-fpm
# Description:       Starts The PHP FastCGI Process Manager Daemon
### END INIT INFO

# Author: Ondrej Sury 

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="PHP 7.2 FastCGI Process Manager"
NAME=php-fpm7.2
CONFFILE=/etc/php/7.2/fpm/php-fpm.conf
DAEMON=/usr/sbin/$NAME

... rest of the code

This meant php7.2-fpm which i had uninstalled was being restarted instead of php7.4-fpm. I zipped it up zip php-fpm-bak.zip php-fpm as a backup and deleted it rm php-fpm. you must have root rights. Then i copied fpm7.4-fpm file to be php-fpm by: cp php7.4-fpm php-fpm. Alternatively instead of coping you can do a symbolic link like this: ln -s /etc/init.d/php7.4-fpm /etc/init.d/php-fpm. I wanted some to understand why the error instead just saying do a symbolic link. So far my Vesta CP is working as expected.

Same as above there is another symbolic link you need to create. For example if you have updated to php7.4, here is how to update the ln ln -s /lib/systemd/system/php7.4-fpm.service /lib/systemd/system/php-fpm.service

Guys let us know if it helped

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darkworks picture darkworks  路  8Comments

luizjr picture luizjr  路  8Comments

progcode picture progcode  路  3Comments

TKaluza picture TKaluza  路  8Comments

SteenSchutt picture SteenSchutt  路  7Comments