Howto: PHP 7.2 & 7.3 on Debian stretch/9 - using phpswitcher 4.0.3

  • Hi guys


    I digged a little bit and tried to use the "old" phpswitcher to also get PHP 7.2 and PHP7.3 into i-mscp. I did this on a vm and did not test the result in real life. If the PHP compilation was successful then it was ok for me...


    As always: there is NO SUPPORT.


    My system setting: Debian 9 (stretch), i-mscp 1.5.3 (2018120800) and phpswitcher 4.0.3 which has built-in PHP-FPM support for PHP 5.3-7.1.


    5.3, 5.4 and 5.5 are no problem - they where EOL before phpswitcher 4.0.3 was released.


    I'll write down the steps to install the other PHP versions.

    5.6 & 7.0 with the last releases (they are EOL since jan 2019)

    and from 7.1 with the last from in mid of august 2019...


    I always installed each version with "perl php_compiler.pl -f x.y" to always force the newest version. Today theese are:

    5.3.29, 5.4.45, 5.5.38, 5.6.40, 7.0.33, 7.1.31, 7.2.21, 7.3.8


    In the attachement there are new patches (5.6.40 from Debian, 7.1-7.3 from Ondřej Surý - from aug 7th 2019) - the folders have to be replaced by theese ones in

    /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler


    5.6.40:

    on my system I had to create a symlink to get curl compiled in the last php 5.6 release:

    Code
    1. cd /usr/local/include
    2. sudo ln -s /usr/include/x86_64-linux-gnu/curl/

    and I took the newer patches from Debian - see the attachement...


    7.0.33: went through without changes...


    7.1.31 (same version as debian 9 default): see patches in attachment


    for 7.2 and 7.3 you need some changes in /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/php_compiler.pl:

    on line 54 extend the hash with versions - so it looks like this (the two lines with # new)

    Code
    1. my %MTTV = (
    2. '5.3' => '5.3.29', # End of life: 14 August 2014
    3. '5.4' => '5.4.45', # End of life: 3 September 2015
    4. '5.5' => '5.5.38', # End of life: 21 July 2016
    5. '5.6' => '5.6.32', # 5.6.40 EOL
    6. '7.0' => '7.0.25', # 7.0.33 EOL
    7. '7.1' => '7.1.11'
    8. ,'7.2' => '7.2.3' # new
    9. ,'7.3' => '7.3.3' # new
    10. );

    And in the Makefile (same folder) you also need to add some lines:

    on line 281 add theese two lines [ just after: 7.1_CONFIG := $(7.0_CONFIG) ]

    Code
    1. 7.2_CONFIG := $(7.0_CONFIG)
    2. 7.3_CONFIG := $(7.0_CONFIG)


    Also copy the two php7.2 & php7.3 folders with the patches into the folder....

    This should be ok for 7.2.21 to be compiled.


    For 7.3.8 another change in the Makefile is needed:

    The block on line 295 should look like this

    Code
    1. prepared: prepared-stamp
    2. prepared-stamp:
    3. [ -f ext/ext_skel ] && mv ext/ext_skel ext/ext_skel.in
    4. ./buildconf --force
    5. touch prepared-stamp

    (the line with "skel" changes!)


    And I had to install some packages - maybe they are already installed:

    Code
    1. apt-get install libpcre2-dev libpcre2-8-0 libpcre2-16-0 libpcre2-32-0 libpcre2-posix0 libzip-dev

    With this settings 7.3.8 was also fine and could be compiled and integrated into i-mscp.



    I hope you are able to install the newer php versions with this howto. Let me know if I have to add or correct some informations.


    Joximu

  • This is what I did before trying to integrate the releases from sury.org.

    Now, i modified a couple of lines in the PhpSwitcher Plugin, so I've always the latest version and I don't need to recompile everything every time...

  • In file /var/www/imscp/gui/plugins/PhpSwitcher/backend/PhpSwitcher.pm

    Change line 926 from:

    Code
    1. if ( $rs || $stdout !~ /PHP\s+(\d+)\.(\d+)\.(\d+)\s+\(cgi-fcgi\)/ ) {

    to

    Code
    1. if ( $rs || $stdout !~ /PHP\s+(\d+)\.(\d+)\.(\d+)\S*\s+\(cgi-fcgi\)/ ) {

    and change line 948 from:

    Code
    1. if ( $rs || $stdout !~ /PHP\s+(\d+)\.(\d+)\.(\d+)\s+\(fpm-fcgi\)/ ) {

    to

    Code
    1. if ( $rs || $stdout !~ /PHP\s+(\d+)\.(\d+)\.(\d+)\S*\s+\(fpm-fcgi\)/ ) {

    Then install every php version you like with every additional module from sury.org (a lot of guides are available, or if you prefer: https://packages.sury.org/php/README.txt)


    The configuration of PHP 5.6 is as follows:

    Common Settings

    Path to PEAR directory: /usr/share/php

    FastCGI Settings

    Path to binary: /usr/bin/php-cgi5.6

    PHP-FPM Settings

    Path to binary: /usr/sbin/php-fpm5.6

    Path to configuration file: /etc/php/5.6/fpm/php-fpm.conf

    Path to pool directory: /etc/php/5.6/fpm/pool.d


    The configuration of PHP 7.0 is as follows:

    Common Settings

    Path to PEAR directory: /usr/share/php

    FastCGI Settings

    Path to binary: /usr/bin/php-cgi7.0

    PHP-FPM Settings

    Path to binary: /usr/sbin/php-fpm7.0

    Path to configuration file: /etc/php/7.0/fpm/php-fpm.conf

    Path to pool directory: /etc/php/7.0/fpm/pool.d


    The configuration of PHP 7.1 is as follows:

    Common Settings

    Path to PEAR directory: /usr/share/php

    FastCGI Settings

    Path to binary: /usr/bin/php-cgi7.1

    PHP-FPM Settings

    Path to binary: /usr/sbin/php-fpm7.1

    Path to configuration file: /etc/php/7.1/fpm/php-fpm.conf

    Path to pool directory: /etc/php/7.1/fpm/pool.d


    The configuration of PHP 7.2 is as follows:

    Common Settings

    Path to PEAR directory: /usr/share/php

    FastCGI Settings

    Path to binary: /usr/bin/php-cgi7.2

    PHP-FPM Settings

    Path to binary: /usr/sbin/php-fpm7.2

    Path to configuration file: /etc/php/7.2/fpm/php-fpm.conf

    Path to pool directory: /etc/php/7.2/fpm/pool.d


    The configuration of PHP 7.3 is as follows:

    Common Settings

    Path to PEAR directory: /usr/share/php

    FastCGI Settings

    Path to binary: /usr/bin/php-cgi7.3

    PHP-FPM Settings

    Path to binary: /usr/sbin/php-fpm7.3

    Path to configuration file: /etc/php/7.3/fpm/php-fpm.conf

    Path to pool directory: /etc/php/7.3/fpm/pool.d


    Please keep in mind that I only use Debian 9 x64, never tested with other distros.

    Please consider that I only use FPM.

    This is a totally unsupported method, I'm sure Nuxwin won't approve that… He is working on something definitive.


    After doing that, you also need to stop the original PHP FPM daemons and also disable them. PHP 7.0 is there only as demo. Debian 9 comes with its original 7.0 version, so I also kept 7.0 as my default PHP version.


    And the result:

    psw.png


    Hope it helps, don't ask for support on that...

    Edited once, last by kess ().

  • Good morning

    joximu

    The tut is fine and seams partitial working for me.

    If i try to compile php7.3 i got this error

    Code
    1. Hunk #1 FAILED at 41.
    2. 1 out of 1 hunk FAILED -- rejects in file ext/pcre/tests/match_flags3.phpt
    3. Patch 0038-php-5.6.0-oldpcre.patch does not apply (enforce with -f)
    4. /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/Makefile:288: recipe for target 'patch-stamp' failed
    5. [ERROR] main: An unexpected error occurred: An error occurred while executing the install MAKE(1) target for php-7.3.3: make: *** [patch-stamp] Error 1

    A patch php 5.6.0? I'm a little bit confused. Wheer can i get the hole patch files from the internet?

    Sascha



    Edit: The first problem is fixed. I'd added the correct verion "7.3.8" in the array. But now i got this error

    Code
    1. -f ext/ext_skel ] && mv ext/ext_skel ext/ext_skel.in
    2. /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/Makefile:302: recipe for target 'prepared-stamp' failed
    3. [ERROR] main: An unexpected error occurred: An error occurred while executing the install MAKE(1) target for php-7.3.8: make: *** [prepared-stamp] Error 1

    I'd changed the block "prepared: prepared-stamp" like you described. But this is the same block like in the script before. Can you check your fix again?

  • Ok.. I got everything working

    The changes above are top! Here my end config

    Code
    1. my %MTTV = (
    2. '5.3' => '5.3.29', # End of life: 14 August 2014
    3. '5.4' => '5.4.45', # End of life: 3 September 2015
    4. '5.5' => '5.5.38', # End of life: 21 July 2016
    5. '5.6' => '5.6.40',
    6. '7.0' => '7.0.33',
    7. '7.1' => '7.1.11',
    8. '7.2' => '7.2.21',
    9. '7.3' => '7.3.8'
    10. );



    Code
    1. prepared: prepared-stamp
    2. prepared-stamp:
    3. -[ -f ext/ext_skel ] && mv ext/ext_skel ext/ext_skel.in
    4. ./buildconf --force
    5. touch prepared-stamp


    The "-" was missing in front of "["

  • 5.6.40:

    on my system I had to create a symlink to get curl compiled in the last php 5.6 release: Code
    cd /usr/local/include
    sudo ln -s /usr/include/x86_64-linux-gnu/curl/

    Good morning joximu


    I'm approving all your work as this is almost how I'm processing... But you should not create such symlink for cURL. Basically put, you need just to add multiarch support through a patch. An example for PHP 5.5 which you can find in the PhpSwitcher/PhpCompiler/php5.5/patches/temporary-path-fixes-for-multiarch.patch patch:


    multiarch.png


    The changes should be similar for PHP 5.6.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • -[ -f ext/ext_skel ] && mv ext/ext_skel ext/ext_skel.in

    Good catch :thumbsup:

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • I think there is another problem.

    On my systems isn't possible anymore to install the extenion "imagick" fpr php 5.6, php7.2, and php7.3

    Code
    1. cd /opt/phpswitcher/%ymd%/php%version%/bin
    2. ./pecl install imagick
    3. echo 'extension = imagick.so' >> /opt/phpswitcher/%ymd%/php%version%/etc/php/conf.d/modules.ini


    I got everytime this error


    Something is not correct with compiling.

  • TheCry


    Ok... I've checked the patches provided by joximu... He has copied them from Ondrey Sury repository AS THIS, without the required modifications... Some patches need to be modified, such as the patches for libtool, else, the required files won't be searched at the right place... Copying the patches from Ondrey Sury without modifying them cannot work because the installation layout is different...


    I'll try to provide new version today because that will become a mess if all people are trying to compile using patches from joxi, even through his job/try is appreciated ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206