PHP extensions different on users PHP CLI than root PHP CLI

Discussion in 'Installation/Configuration' started by beryl, Jul 3, 2020.

  1. beryl

    beryl Member

    Why does this happen and how can I enable the same extensions for the PHP cli for shell users?
    I've really tried searching for this issue, but it's basically impossible to find anything relevant.

    EDIT: Is this a Jail issue? Do I need to update jail after setting a new default PHP CLI?
     
    Last edited: Jul 3, 2020
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    yes,
    you need to include all versions of php into a jail, and update the jail if you add another php version.

    that will allow the shell user to use any version of the php cli.
    you can't currently automatically set the default cli php version they use to match the website fpm php version

    if you/they want the a specific php version to be used when just using /usr/bin/php instead of /usr/bin/php# then you'll need to set an alias for it in .bashrc in their home folder.
     
    beryl likes this.
  3. beryl

    beryl Member

    I managed to get that working and now I could use most extensions, however, mysqli isn't loading (But works on root).

    This is the entry I added to the jail:

    Code:
    [php]
    comment = The PHP Interpreter and Libraries
    executables = /usr/bin/php, /usr/bin/php7.4, /usr/bin/php7.3, /usr/bin/php7.2, /usr/bin/php5.6
    directories = /usr/lib/php, /usr/share/php, /usr/share/php, /etc/php, /usr/share/php-geshi,     /usr/share/zoneinfo
    includesections = env
     
  4. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    mysql(i) may b working ok, but just not connecting if you're trying to connect to localhost.
    the mysql socket isn't included in the jail, if it's on the same partition, you can bind mount it, there are instructions somewhere on this forum,
    however that can have other complications.
    try connecting to 127.0.0.1 instead of localhost so it uses a tcp connection instead of the unix socket.

    if you're trying to use something like wp-cli, edit wp-config.php

    find
    Code:
    /** MySQL hostname */
    define('DB_HOST', 'localhost:3306');
    
    
    and replace it with
    Code:
    /** Tell WP-CLI to use TCP instead of socket connection */
    if ( defined( 'WP_CLI' ) && WP_CLI ) {
    /** MySQL hostname for WP-CLI */
    define('DB_HOST', '127.0.0.1:3306');
    } else {
    /** MySQL hostname */
    define('DB_HOST', 'localhost:3306'); }
    
    if you're using some other software/cms, make a similar change wherever the database connection is defined.
     
    beryl likes this.
  5. beryl

    beryl Member

    That was the exact issue, I saw it on occasion when web-searching the issue but it didn't hit me until you pointed it out!
    It works now, thanks a lot!
     
  6. beryl

    beryl Member

    Ah, mess, another issue.

    Code:
    77 error setting certificate verify locations:
      CAfile: /etc/ssl/certs/ca-certificates.crt
      CApath: /etc/ssl/certs
    Any ideas?

    EDIT: Found the solution & issue described here https://www.howtoforge.com/community/threads/jailkit-copy-over-ca-certificates.75927/
     
    Last edited: Jul 3, 2020
  7. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    add this line:
    Code:
    regularfiles= /etc/ssl/certs/ca-certificates.crt
    to the netutils section in /etc/jailkit/jk_init.ini
    and then update the users jail.
     
    beryl likes this.
  8. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    @beryl you might try grabbing jk_init.ini.master from the stable-3.1 git branch and see how things work for you.
     
  9. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    one thing which i didn't pick up on earlier.
    as i understand this, you have changed which php version your server OS uses by default, if this is right, set it back to what is was before.
    do NOT change the default php version on a server running ispconfig.
    it'll lead to all sorts of pain....
     

Share This Page