PHP 7 Database Errors to localhost

Discussion in 'ISPConfig 3 Priority Support' started by Nilpo, Mar 18, 2017.

  1. Nilpo

    Nilpo Member HowtoForge Supporter

    I'm running a perfect server on CentOS 6.8. I recently added PHP 7.0 and 7.1. When I switched over sites, I began getting database errors.
    Code:
    mysqli_real_connect(): (HY000/2002): No such file or directory
    Changing 'localhost' to '127.0.01' resolves the error and allows everything to function properly. I first got the idea to try from this question on StackOverflow.

    In my opinion, this is just a workaround. What's the real solution? Using "localhost" should work.
     
  2. Nilpo

    Nilpo Member HowtoForge Supporter

    After much more Googling, I suspected that PHP was not loading the correct location for the mysql socket. (In short, using localhost loads from socket, using IP forces it to load from TCP/IP port.)

    After editing php.ini and filling in the following value, everything started working fine.
    Code:
    mysqli.default_socket = /var/lib/mysql/mysql.sock
    So the question becomes: Did the default value change in PHP 7.*? The docs don't really indicate what the default actually is.

    Note: I installed PHP 5.6, 7.0, and 7.1 all from source at the same time. Only PHP 7.* is affected by this. PHP 5.* works just fine with that setting blank by default.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    PHP 7.x changed a lot, so it won't make me wonder if they changed that was well.
     
  4. Nilpo

    Nilpo Member HowtoForge Supporter

    At least we know the fix now.

    On a side note, the tutorials still don't have APCU working but I was able to install APCu, memcache, and memcached (with exception of APCu on PHP 7.1 which is still unsupported). Although, I was not able to install the APCu Backward Compatibly Module.
     

Share This Page