Default php version for ssh users should be "in sync" with web site settings

Discussion in 'Feature Requests' started by atnetws, May 18, 2020.

  1. atnetws

    atnetws New Member

    Hi folks,
    I have several servers using ispConfig's multiple php version feature, which works just fine concerning requests coming from Apache.
    It would be very nice if ispConfig kept the chosen php version "in sync" for web and ssh.
    Assuming the following situation:
    • php set to 7.3
    • TYPO3 10.4 in composer mode
    • Web requests work fine
    • Executing composer in a shell fails to execute if the OS's default php version is lower than 7.2
    I know that calling the matching php binary directly would do the trick, but that only works when calling composer manually and usually fails if there are additional scripts definied in composer.json, as composer calls them using /usr/bin/php, which is the wrong one then.

    Besides, this behavour breaks any attempts to use advanced publishing methods like CI/CD, as it makes it impossible to call local cleanup scripts like typo3cms database:updateschema remotely.

    Long story short: please provide a possibility to automatically or manually set the same php version for web and ssh. It should be the default behaviour to keep both versions in sync.

    Greetings
    Marcus
     
    ahrasis likes this.
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    it can be done manually already.
    include all the php versions in your jailkit:

    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/php7.1, /usr/bin/php7.0, /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
    
    then create an alias for the required php version in /home/%username%/.bashrc, eg:
    Code:
    alias php='/usr/bin/php7.3'
    

    only way i can see it being done automatically is to run another mysql query whenever the php version on the website changes, to check if the parent_domain_id matches in the shell_user table, and then create/edit the .bashrc file if it does, in all /home/%username%/ folders for usernames with a matching parent_domain_id, and also once for the matching puser field/user. not sure just how easy/hard that would be to implement though.
     
    ahrasis likes this.
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    The problem that I see with automatic updating of the CLI php version is that ISPConfig can not know if all PHP versions exist as CLI version and where these cli versions are. Soem users might have installed all additional PHP versions as FPM versions only, e.g. on Nginx systems, so there is no matching CLI php.
     
    ahrasis likes this.
  4. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    This should be pretty doable, by generating some jk_init.ini sections based on configured php version info.

    In PHP Settings (system default php version), you add a path for the cli binary and the cli php.ini; you also need a field for jailkit paths specific to this php version; and finally a field for common (all versions) php jailkit paths and common php jailkit includesections. The default system php would always be added to jk_init.ini.

    In the Additional PHP Versions you need a tab for "CLI Settings" with fields for the paths to the binary and php.ini. If those are set, a section in jk_init.ini is created for this php version, which includes the php_common section (configured above), and this php version is copied into the jail. If these are unset, the system default php version would be added to the jail, rather than the version matching the website settings.

    The generated jk_init.ini sections would look similar to this:

    Code:
    [env]
    comment = /usr/bin/env for environment variables
    paths = env
    
    # Debian 10 default php version is 7.3
    [default_php]
    comment = default php version and libraries (identical to php7_3)
    paths = /usr/bin/php7.3, /usr/lib/php/7.3/, /usr/lib/php/20180731/, /usr/share/php/7.3/, /etc/php/7.3/cli/, /etc/php/7.3/mods-available/
    includesections = php_common
    
    [php_common]
    comment = common php directories and libraries
    # notice:  potential information leak
    #  do not add all of /etc/php/ or any of the fpm directories
    #  or the php config (which includes custom php snippets) from *all*
    #  site which use fpm will be copied to *every* jailkit
    paths = /usr/bin/php, /usr/lib/php/, /usr/share/php/, /usr/share/zoneinfo/
    includesections = env
    
    [php5_6]
    comment = php version 5.6
    paths = /usr/bin/php5.6, /usr/lib/php/5.6/, /usr/lib/php/20131226/, /usr/share/php/5.6/, /etc/php/5.6/cli/, /etc/php/5.6/mods-available/
    includesections = php_common
    
    [php7_0]
    comment = php version 7.0
    paths = /usr/bin/php7.0, /usr/lib/php/7.0/, /usr/lib/php/20151012/, /usr/share/php/7.0/, /etc/php/7.0/cli/, /etc/php/7.0/mods-available/
    includesections = php_common
    
    [php7_1]
    comment = php version 7.1
    paths = /usr/bin/php7.1, /usr/lib/php/7.1/, /usr/lib/php/20160303/, /usr/share/php/7.1/, /etc/php/7.1/cli/, /etc/php/7.1/mods-available/
    includesections = php_common
    
    [php7_2]
    comment = php version 7.2
    paths = /usr/bin/php7.2, /usr/lib/php/7.2/, /usr/lib/php/20170718/, /usr/share/php/7.2/, /etc/php/7.2/cli/, /etc/php/7.2/mods-available/
    includesections = php_common
    
    [php7_3]
    comment = php version 7.3
    paths = /usr/bin/php7.3, /usr/lib/php/7.3/, /usr/lib/php/20180731/, /usr/share/php/7.3/, /etc/php/7.3/cli/, /etc/php/7.3/mods-available/
    includesections = php_common
    
    The only thing remaining is to create the /usr/bin/php symlink inside the jail to the actual version-specific binary.

    And a last note, are there any existing gitlab issues on this? I sure thought there was discussion on the ability to select the jailkit php version in the past, but can't find it in some searching.
     
    ahrasis likes this.
  5. topogigio

    topogigio Member

    Hi,
    is there any news about this?
    I currently assign in website options php to jailkit (eg. filling in "Jailkit chroot app sections" with "php8_0") then I create a .bashrc file that points "php" to "php8.0", but is really long to maintain, specially when I perform a php upgrade.

    thanks for great job
     

Share This Page