PHP 5.6 multiversion on Debian 9 cannot connect to the database

Discussion in 'ISPConfig 3 Priority Support' started by gscaglia, Oct 19, 2018.

  1. gscaglia

    gscaglia Member HowtoForge Supporter

    Hi,
    in a production web server with native Debian 9 Stretch and ISPConfig 3.1.13 (Apache) I installed the additional PHP versions following the how-to https://www.howtoforge.com/tutorial/how-to-install-php-5.6-and-7.1-on-debian-9-stretch/
    For PHP versions 7 (so the default 7.0, the 7.1 and 7.2) no problem.
    Also version 5.6 seems to work well (both Fast-CGI and PHP-FPM) but when a website needs a database (MariaDB) connection, e.g. for WordPress but not only, this error is returned: "Error establishing a database connection".
    On the page phpinfo, PHP version is correct (5.6.33) and the mysqli function is active (mysqlnd 5.0.11-dev - 20120503).
    What can I do to solve the problem?
    Thanks a lot
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Any further errors in website error.log of that website for the mysql connection problem?
     
  3. gscaglia

    gscaglia Member HowtoForge Supporter

    The file log/error.log are empty.
    Activating WordPress debug mode, in the wp-content/debug.log there is this error:
    [19-Oct-2018 07:39:51 UTC] PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/clients/client33/web63/web/wp-includes/wp-db.php on line 1531

    The line 1531 on wp-db.php is this:
    mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $post, $socket, $client_flags );

    If I change Fast-CGI (or PHP-FPM) on PHP 7.x the same website works fine.

    May I try to install PHP 5 on the system (apt-get install php5 php5-mysql)?
    Because in the open_basedir (phpinfo) there is also /usr/share/php5 folder (that doesn't exist on the file system) and there is not /opt/php-5.6 folder, is it normal?
     
    Last edited: Oct 19, 2018
  4. till

    till Super Moderator Staff Member ISPConfig Developer

  5. gscaglia

    gscaglia Member HowtoForge Supporter

    Following your link I completed these two variables in the /opt/php-5.6/lib/php.ini:
    • pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock
    • mysqli.default_socket = /var/run/mysqld/mysqld.sock
    For new versions of Wordpress now the problem is fixed, but not for the version 3.2.1.
    I have to transfer a site in Wordpress 3.2.1 that works perfectly on another web server, almost identical to the new one: the only difference is that the old server started with Debian 8, and then PHP 5, only to be upgraded to Debian 9 with PHP 7.
    On that server, same site in Wordpress 3.2.1 with PHP version 5.6.33 it runs smoothly.

    Any other idea?
     
    Last edited: Oct 19, 2018
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Did you try to set the mysql host in wordpress config file to 127.0.0.1 ?
     
  7. gscaglia

    gscaglia Member HowtoForge Supporter

    Yes, it's the first solution that I tryed but works only for the new versions of Wordpress, not for the 3.2.1.

    I solved following the how-to https://tecadmin.net/install-php-debian-9-stretch/
    I installed only php5.6 (put the 7.1 and 7.2 in the /opt folder is better and works fine).

    I added php5.6-fpm and php5.6-cgi modules (they are not present in that how-to) and I compiled the fields on ISPConfig -> System -> Additional PHP Versions without problems.

    The php5.6 package by sury.org behaves exactly like php7.0, it doesn't open php5 folder but put the files in /etc/php/5.6 and in /usr/share/php5.6-module.

    This way works and it's even easier as an installation, do you think there may be problems in production?

    Thanks a lot
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    That should be fine as well.
     
    gscaglia likes this.

Share This Page