MultiPHP Setup on Ubuntu 18.04.06 / Adding 7.4 / Getting ERROR 500

Discussion in 'Installation/Configuration' started by pssadm, Jul 10, 2022.

  1. pssadm

    pssadm New Member

    Hi all,
    I have a problem, that has stumped me for quite some time now. Wondering if anyone knows what I'm doing wrong.
    I have an UBUNTU 18.04 server (running as an LXC container) - has been working for many years without issue. Lately, I have the need to add PHP7.4 in order to get Nextcloud secured. Problem is, every time I follow the instructions online. I add the PHP version as I have done in the past.. but this time, the second I load the index.php I get an Error 500 (yellow) screen of death. :(

    By the time, I finished troubleshooting, I broke the server pretty badly. Had to restore from backup. Now, I'm all but paralyzed. Any ideas on why this is happening? I've even tried multiple ways to add the PHP. All of which are relatively straight forward.

    (Example)
    sudo apt-get update
    sudo apt -y install software-properties-common
    sudo add-apt-repository ppa:eek:ndrej/php
    sudo apt-get update
    sudo apt-get install php7.4​
    So far so good.
    I knew that it would change the default version as Till has mentioned, so I reverted back to PHP7.2 using
    sudo update-alternatives --set php /usr/bin/php7.2​

    I checked that ISPCONFIG was working. And it was. I checked the site using an index.php file that contained a PHP script <?phpinfo();?>
    It worked fine on 7.2.

    I added the Alternative PHP version to ISPConfig in the SERVER Settings and chose PHP7.4 as the default for that website.
    When testing the site, I instantly get an ERROR 500. Yet, when I go to the command line and use the command:
    /usr/bin/php7.4 /var/www/clients/client1/web1/web/index.php. It seems to execute perfectly.

    I've done just about everything I can think of. I also added the supporting php7.4- modules, in the manner below. It did not help. More over, it also added php8.1 to the mix. Not sure why.

    apt-get -y install php7.4 php7.4-common php7.4-fpm php7.4-gd php7.4-mysql php7.4-imap php7.4-cli php7.4-cgi php-pear php7.4-curl php7.4-intl php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php-memcache php-imagick php-gettext php7.4-zip php7.4-mbstring php7.4-soap php7.4-common php7.4-opcache php7.4-mysql​

    CGI PATH INFO:
    Path to the PHP FastCGI binary: php7.4-cgi
    Path to the php.ini directory: /etc/php/7.4/cgi
    I wonder if this is a simple as missing the correct path or some alias file? Any help would be greatly appreciated.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Use the full path here: /usr/bin/php7.4-cgi
     
  3. pssadm

    pssadm New Member

    It can't possibly be that easy!!! Going to try now... will report back shortly.
     
  4. pssadm

    pssadm New Member

    Nope, didn't seem to work. Is there anywhere I can see a more meaningful error? I don't see anything in the apache error or access log of consequence. Access log simply repeats the error 500 message.

    Thanks for following up Till! - - much appreciated.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    You must change the php version of the site afterwards to a different version, press save, and then change it back and press save.
    You can find the error in the error.log of the website.
     
    pssadm likes this.
  6. pssadm

    pssadm New Member

    Thank you so much Till! You are amazing. I've tried a million times.. I couldn't believe my eyes when it "just worked"!! I just had to know if I could redo it without the massive amount of modifications I made early on. So I cloned my original 18.04 with php7.2 running and I was able to get it working in 5 minutes.

    I will share my notes if it can help anyone else experiencing something similar:

    Code:
    Install Instruction within Ubuntu 18.04.xx:
    sudo apt-get update
    sudo apt -y install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install php7.4
    Sudo apt-get install php7.4-cgi
    Sudo apt-get install php7.4-fpm
    sudo update-alternatives --set php /usr/bin/php7.2
    sudo update-alternatives —-set php /usr/bin/php-cgi7.2
    OR select the version manually :
    sudo update-alternatives --config php
    sudo update-alternatives --config php-cgi
    Service apache2 restart
    
    In Server settings of ISPCONFIG choose Additional PHP Versions
    Add:
    php7.4
    
    FastCGI Settings
    Path to the PHP FastCGI binary: /usr/bin/php-cgi7.4
    Path to the php.ini directory:/etc/php/7.4/cgi
    
    PHP-FPM Settings:
    Path to the PHP-FPM Init Script: php7.4-fpm
    Path to the php.ini directory: /etc/php/7.4/fpm
    Path to the PHP-FPM pool directory: /etc/php/7.4/fpm/pool.d
    
    That should do the trick. If you aren’t sure about the name of the binary corresponding to your php version… run the following command:
    
    ls -la /usr/bin/php*
    
    — you directory should look something like this —
    lrwxrwxrwx 1 root root      21 Apr  6 01:34 /usr/bin/php -> /etc/alternatives/php
    -rwxr-xr-x 1 root root 4903960 Jul  6 12:23 /usr/bin/php7.2
    -rwxr-xr-x 1 root root 4654872 Jun 27 08:20 /usr/bin/php7.4
    lrwxrwxrwx 1 root root      25 Apr  6 01:34 /usr/bin/php-cgi -> /etc/alternatives/php-cgi
    -rwxr-xr-x 1 root root 4797744 Jul  6 12:23 /usr/bin/php-cgi7.2
    -rwxr-xr-x 1 root root 4548040 Jun 27 08:20 /usr/bin/php-cgi7.4
    That’s all folks!
    Thanks again Till!
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

Share This Page