PHP 7.0 Exorcism

Discussion in 'Installation/Configuration' started by Gray Consulting, Jul 7, 2020.

  1. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Greetings all:
    We are at the tail end of numerous system upgrades to our LAMP server, including moving from ubuntu 16.04 --> 19.10 -- > 20.04, and PHP from 7.0 to 7.4. We run a vhost config, including email services. All systems are running normally, except for php (under apache, not cli):

    PHP CLI:
    Code:
    [email protected]:/etc/php$ php -v
    PHP 7.4.7 (cli) (built: Jun 12 2020 07:44:21) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    MySQL:
    upload_2020-7-7_9-35-43.png
    Yet no matter we tweak, poke and prod, apache is still trying to pull the wrong version (7.0, which was the last actively used version), so things go pear-shaped from there. Currently, any of our hosted sites that don't use a db work fine, but those that do, appropriately get the same error:
    Code:
    Uncaught Error: Call to undefined function mysqli_connect()
    (the path identified as /etc/php/7.0... does not exist)​
    upload_2020-7-7_9-45-46.png

    Only 7.3 and 7.4 are installed on the system; 7.3 is disabled, and 7.4 is enabled, based on apache mods-availabe and sites-available configs.

    We're hoping someone out there has our 'duh' moment, but we're just not seeing it. As always, any help or directly would be much appreciated.
     
  2. Steini86

    Steini86 Active Member

    You can try removing everything related to php7.0 from your system, if you don't want to use it (apt remove php7.0*)
    It looks like you are using PHP7.0 via CGI/FastCGI. You should change that apache module to php7.4 then.
    Look in your vhost config file and at the activated apache modules.
     
  3. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thank you Steini!

    You are spot on - I thought I had covered that rabbit hole, but seems I hadn't dug deep enough. Here's what I found:
    Code:
    [email protected]:~$ cat /var/www/php-fcgi-scripts/web9/.php-fcgi-starter
    ...
    PHPRC="/etc/php/7.0/cgi/"
    export PHPRC
    ...
    I tried updating all starter files (for each domain, and one under ispconfig), with the new /etc/php/7.4/fpm/ directory path, but to no avail - the only change was this:
    upload_2020-7-7_14-35-14.png

    I also found this:
    Code:
    ubuntu@ip-172-31-25-207:~$ sudo ls -l /etc/init.d/php*
    -rwxr-xr-x 1 root root 4294 Jul  7 19:39 /etc/init.d/php7.0-fpm
    -rwxr-xr-x 1 root root 4294 Jun 12 07:44 /etc/init.d/php7.4-fpm
    Wondering why the 7.0-fpm even exists, much less that it's dated today. I have since renamed it, but no change to phpinfo results. (I had long ago uninstalled/removed all things 7.0, or thought I did.)

    I have a sneaking suspicion that ISPConfig is possibly related here; we're considering a re-install, but don't want to hose everything else in the process.

    Thanks again for the info - I'm sure we're in the right rabbit hole, just not sure how to fix it.

    Cheers ~
     
  4. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    One other thought: since phpmyadmin loads and works fine, and uses 7.4, can I look at that config for clues?

    Cheers ~
     
  5. Steini86

    Steini86 Active Member

    You should have said, that you are using ispconfig. I was under the impression, you handle the files by yourself...

    In ISPC, go to System -> Config -> Server Config -> Web -> PHP and change the paths from php7.0 to php7.4
    Then go to Tools -> Resync and resync websites (rewrites config for all websites with new php settings)

    [Edit]
    Also consider that Ubuntu 20.04 is only supported by ISPC 3.1.16 (to be released soon):
    You might want to try the git version, though.
     
    Last edited: Jul 8, 2020
  6. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Ugh - under normal circumstances, that would have been perfect but since it's all on the same server, not even ispconfig will load

    We even tried an ispc update, but that reported nothing to update.

    Thanks again for these suggestions!
     
  7. Steini86

    Steini86 Active Member

    It should be possible to change the release channel. First try with git-stable, if that does not give you 3.1.16 then use git-master (untested). OR:
    Code:
    cd /tmp
    wget https://git.ispconfig.org/ispconfig/ispconfig3/-/archive/stable-3.1/ispconfig3-stable-3.1.tar.gz
    tar xvfz ispconfig3-stable-3.1.tar.gz
    cd ispconfig3_install/install
    php -q update.php
    choose reconfigure services (at least for apache/web).
     
    Gray Consulting likes this.
  8. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thanks Steini -
    Confirmed - did end up with 3.1, but no solution to our problem.

    That being the case, I'm happy to take this over the wall to the ISPConfig folks, and see if there's a manual way to correct ispc pointing to 7.0. You've been so helpful already; don't want to eat up more of your time... :p (Pretty sure this the second time you've rescued us!)

    Thanks!
     
    Steini86 likes this.
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    I've moved your post to the ISPConfig forum now. In your first post, you said you have LAMP system and posted in the forum for servers without ISPConfig, so nobody could guess that you are actually using ISPConfig.

    Like as @Steini86 mentioned in #5:

    1) Edit all php paths under System > server settings > web and System > server settings > fastcgi to match the new PHP version. Especially that the fastcgi php binary mentioned on fastcgi tab is really your php 7.4
    2) Run tools > resync to apply the changes.

    Do not edit any fastcgi or other ispconfig related config files manually.

    And one guess, you might have set a wrong default PHP version in the OS outside of ispconfig. Check and correct that with:

    update-alternatives --config php
    update-alternatives --config php-cgi
     
    Gray Consulting likes this.
  10. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thank you Till (and Steini) -
    And apologies for not starting this thread in the right place.

    Sadly we can't do anything in ISPConfig console, since it doesn't load (the underlying versioning error results in missing mysqli() errors, since 7.0 or it's components are not even installed.

    update-alternatives for php resulted as expected, 7.4 (auto mode) as the default version.
    update-alternatives for php-cgi resulted "no alternatives for php-cgi"
    Till, I also saw your other thread regarding Ubuntu 20.4, php 7.4, (from April), not recommending ispconfig on those new stacks (yet).

    So all those things considered, and especially as we need this server to be a production resource, we're going to start fresh with an ubuntu 18.04 server, ispconfig 3.1, and php 7.3

    Thank you both again, for all the help & direction - we appreciate it so much!!

    ~ Cliff
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    When you get these errors, then you must have php installed without mysqli module. It can't be missing PHP 7.0 as then no error would be returned at all when no PHP is installed. So when you see that error, then PHP is installed an no matter whcih version it is, this php lacks mysqli support. Install mysqli and all other required modules for that PHP version. You can find which version it is by running:

    php --version

    Then use apt and install the missing modules for that version.

    You can use the ispconfig from git-stable branch on Ubuntu 20.04, but it has not been finally tested and has not been released yet, but it should work quite well.
     
  12. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thanks Till -

    Couldn't agree more; that makes perfect sense to me, but our actual results continue to confuse.

    Code:
    ubuntu@ip-xxx-xxx-xxx-xxx:~$ php --version
    PHP 7.4.7 (cli) (built: Jun 12 2020 07:44:21) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.7, Copyright (c), by Zend Technologies
    If I try to install php7.4-mysql (or other related modules), the result is always the same - already installed
    Code:
    ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo apt install php7.4-mysql
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    php7.4-mysql is already the newest version (7.4.7-1+ubuntu19.10.1+deb.sury.org+1).
    ...
    0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
    Which makes sense (that 7.4 is installed, with all the mysql & other modules), given phpmyadmin runs fine:
    upload_2020-7-8_12-58-4.png

    As a possible solution, I tried re-installing php7.0 (my thinking being, if I can get ispconfig console to load, I can change the php version there), but struck out there as well:
    Code:
    ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo apt install php7.0
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package php7.0
    (I suspect I need to define a different repository to install 7.0, unless you think that's a bad idea anyway...?)

    Good to know re 20.04: if we do go with a full rebuild, we'll go with that. Otherwise, I don't want to burn a ton of your time, over a server that I think I have hosed over the course of multiple upgrades (16.04 --> 19.10 --> 20.04, and php from 7.0 --> 7.3 --> 7.4), and possibly too much tweaking with config files. Just keep getting stuck on the reality that everything's there, but apache (?) still wants to point to 7.0...

    As always, thanks so much for all the help/input.

    ~ Cliff
     
  13. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Try: using phpmyadmin, check the server table, in the config field there are PHP settings, update those from 7.0 to 7.4, then update from git-stable and reconfigure services. Do not edit server.config in phpmyadmin's inline editor, click the button to edit the full row. You might backup your db first as well.
     
    Gray Consulting likes this.
  14. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thanks Jesse!
    Bingo on the config field updates; there were a number of fields I had to update. I included the obvious rows that changed, and the entire FastCGI section, based on the errors we're seeing now:
    Code:
    php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php7.4:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom
    php_ini_path_apache=/etc/php/7.4/apache2/php.ini
    php_ini_path_cgi=/etc/php/7.4/fpm/php.ini
    php_fpm_init_script=php7.4-fpm
    php_fpm_ini_path=/etc/php/7.4/fpm/php.ini
    php_fpm_pool_dir=/etc/php/7.4/fpm/pool.d
    php_fpm_socket_dir=/etc/php/7.4/fpm/pool.d
    
    [fastcgi]
    fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/
    fastcgi_starter_script=.php-fcgi-starter
    fastcgi_alias=/php/
    fastcgi_phpini_path=/etc/php/7.4/fpm/
    fastcgi_children=8
    fastcgi_max_requests=5000
    fastcgi_bin=/usr/bin/php-cgi
    fastcgi_config_syntax=2
    ... and here's the error we see now:
    Code:
    [fcgid:warn] [pid 1385] (104)Connection reset by peer: [client 67.176.252.29:49988] mod_fcgid: error reading data from FastCGI server
    I'm sure you're close; it looks like i just need the right tweaks to the config? Can I just 'turn off' FastCGI, since FPM replaces it?

    Thanks again Jesse!

    ~ Cliff
     
  15. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Should be /etc/php/7.4/cgi/php.ini
    Should be /etc/php/7.4/cgi/

    Ensure the php7.4-cgi package is installed and /etc/alternatives/php-cgi points to /usr/bin/php-cgi7.4,
    reconfigure services (ie. run update.php) again, check that /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter got written with "PHPRC=/etc/php/7.4/cgi/", then test if it works.

    No, FastCGI is used for the ISPConfig vhost (see /etc/apache2/sites-enabled/000-ispconfig.vhost).
     
    Gray Consulting likes this.
  16. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Jesse, you da man!

    I had to resolve a number of outstanding dependencies before I was able to install php7.4-cgi. (Turns out ubuntu 19.10 hadn't been fully exorcised either)

    ISPConfig is loading, and our websites are back. (Roundcube and phymyadmin are now returning file-not-found errors, but pretty sure I know how to resolve that...)

    Thanks again to Jesse, Till, and Steini - we owe you big time!

    ~ Cliff
     

Share This Page