Posts by UncleSam

    kess thx for the information, I found it using wayback (https://web.archive.org/web/20…hp?id=plugins:phpswitcher).


    I also was able to replace all compiled versions with the packaged versions. I have just a short question about that:

    Is this also installing all needed php versions from the package (which makes my howto obsolete - almost) or is the installation still a part you have to do on your own?


    Short description how to useit:

    1. Add 8.0 and 8.1 to /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/php_compiler.pl
    2. run perl /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/php_compiler.pl --register --packaged --packaged-only 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1

    WARNING This script is not supported by i-MSCP team WARNING


    Hi there,


    I was very frustrated bringing php 8.0 and 8.1 up with the PhpSwitcher plugin. So I checked alternatives and found other tools like IspConfig which are using package reposirories with precompiled php versions. So I started to check if these version could be used for the PhpSwitcher as it makes the implementing it into I-MSCP more easier. And the good part is that I found a solution.


    ATTENTION:

    • This HowTo is for Ubuntu and tested only on Ubuntu.
    • Use at your own risk!
    • I made this after bringing the new version to work - so some steps could be not precised as I want them to be.
    • In some cases you need root access - in these cases place a sudo in front of the commands.


    If all precompiled versions are working (which they should), you can install the following packages:

    • 5.6
    • 7.0
    • 7.1
    • 7.2
    • 7.3
    • 7.4
    • 8.0
    • 8.1

    Changelog:

    Requirements:

    • phpSwitcher (paid module)
    • shell access to your server (with root permissions)
    • shell knowledge (never trust online shell commands!)


    Installing the package repository:

    To install the packages I use the Ondrej php versions: https://deb.sury.org/


    Shell-Script
    1. apt install software-properties-common
    2. add-apt-repository ppa:ondrej/php
    3. apt-get update


    Install php version with basic needs (example is for php 8.1):

    Shell-Script
    1. apt-get install php8.1-cgi php8.1-fpm php8.1-dev libapache2-mod-php8.1

    In my case I install all the packages I need:

    Shell-Script
    1. apt-get install php8.1-cgi php8.1-fpm php8.1-xml php8.1-bz2 php8.1-sqlite3 php8.1-pdo-sqlite php8.1-mysql php8.1-mbstring php8.1-imap php8.1-imagick php8.1-gd php8.1-curl php8.1-apcu php8.1-dev php8.1-memcached php8.1-pdo-mysql php8.1-pdo-sqlite php8.1-pgsql php8.1-zip php8.1-redis php8.1-mcrypt libapache2-mod-php8.1

    (In some cases an apt-get upgrade is needed after this step.)


    Install PEARL (optional):
    WARNING: This is only needed if you want to configure the versions on your own and only if you want a seperate folder for each php version!

    Installation of PEARL is really easy but you need to make sure to change the directory:

    Shell-Script
    1. # create the folders you want pear to be installed to (in my case /opt/pear/8.1)
    2. mkdir /opt/pear
    3. mkdir /opt/pear/8.1
    4. # download installer and start it
    5. cd /opt/pear
    6. wget http://pear.php.net/go-pear.phar
    7. php8.1 /opt/pear/go-pear.phar # see below before executing!

    The last command opens the following list, the paths below are a suggestion:

    Now press 1 and change the path to /opt/pear/8.1

    After that press 12 and change it to /opt/pear/pear8.1.conf


    Now it should look like:

    Press enter to start the installation process.


    Installing additional pecl packages (optional):

    WARNING: First of all check if there is a precompiled packages which comes with the Ondrej packages using apt search php | grep mymodulename.

    WARNING: I had troubles using this and avoided using it. So be careful with this and test it before trying to use it productive!


    First of all you need to change the default php version:

    Shell-Script
    1. update-alternatives --set php /usr/bin/php8.1
    2. update-alternatives --set php-cgi /usr/bin/php-cgi8.1
    3. update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php8.1
    4. update-alternatives --set php-config /usr/bin/php-config8.1
    5. update-alternatives --set php-fpm.sock /run/php/php8.1-fpm.sock
    6. update-alternatives --set phpize /usr/bin/phpize8.1

    Now install your pecl module - in this example the module is called <module>:

    Shell-Script
    1. printf '\n' | pecl install -f <module>
    2. PHP_EXT_DIR=$(/usr/bin/php-config8.1 --extension-dir) \
    3. && echo "extension = <module>" > /etc/php/8.1/mods-available/<module>.ini
    4. if [ -f /etc/php/8.1/mods-available/<module>.ini ]; then
    5. ln -s /etc/php/8.1/mods-available/<module>.ini /etc/php/8.1/cgi/conf.d/50_<module>.ini
    6. ln -s /etc/php/8.1/mods-available/<module>.ini /etc/php/8.1/apache2/conf.d/50_<module>.ini
    7. ln -s /etc/php/8.1/mods-available/<module>.ini /etc/php/8.1/cli/conf.d/50_<module>.ini
    8. ln -s /etc/php/8.1/mods-available/<module>.ini /etc/php/8.1/fpm/conf.d/50_<module>.ini
    9. echo "extension does not exist: /etc/php/8.1/mods-available/<module>.ini"
    10. fi

    Switch PHP version back to your old one - in this case 7.0:

    Shell-Script
    1. # some of the commands below could fail due to not installed in your main php version
    2. update-alternatives --set php /usr/bin/php7.0
    3. update-alternatives --set php-cgi /usr/bin/php-cgi7.0
    4. update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php7.0
    5. update-alternatives --set php-config /usr/bin/php-config7.0
    6. update-alternatives --set php-fpm.sock /run/php/php7.0-fpm.sock
    7. update-alternatives --set phpize /usr/bin/phpize7.0


    Install Ioncube (optional):

    First of all we need to download the ioncube package:

    Shell-Script
    1. mkdir /opt/ioncube
    2. cd /opt/ioncube
    3. wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
    4. tar -xzf ioncube_loaders_lin_x86-64.tar.gz


    Now install it for the version you wanna use. At this moment php8.1 is not in the list but shown above as an example:

    And remove the garbage 8):

    Shell-Script
    1. rm -rf /opt/ioncube


    Finally:

    After this you need to restart all php services. I also added some more details about the output versions, but in general they are not really needed:


    Installing in I-MSCP:

    There are two ways to install the packages:

    Using built in phpSwitcher function:

    Make sure the version is in the compiler file (not known versions are not searched and therefore cannot be added). Check the file /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/php_compiler.pl and add the versions you want and need (the most recent versions can be found at https://www.php.net).


    After that you can add the php versions with the following command (only specify the versions you want or simply do not specify any version to add them all):

    WARNING: If you already have a configured compiled version this is going to overwrite them!

    Code
    1. perl /var/www/imscp/gui/plugins/PhpSwitcher/PhpCompiler/php_compiler.pl --register --packaged --packaged-only 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1


    Do it on your own:

    All you need now is to switch to your new php version. So add it with the following parameters (example still with 8.1):

    NameValue
    General -> Pear folder
    /opt/pear/8.1/share/php
    or if you do not have an own folder for pear
    /usr/share/php
    FastCGI -> path to binary file
    /usr/bin/php-cgi8.1
    PHP-FPM -> path to binary file
    /usr/sbin/php-fpm8.1
    PHP-FPM -> path to config file
    /etc/php/8.1/fpm/php-fpm.conf
    PHP-FPM -> path to pool folder
    /etc/php/8.1/fpm/pool.d


    Upgrade:

    If there is a new version in the package repository all you need to do is a normal packages update. As this has not happened till this howto was made I recommend to check the admin panel if everything works fine.

    Finally 2 (optional):

    If you liked it please leave a thumbs up :thumbsup:.


    WARNING This script is not supported by i-MSCP team WARNING

    If I set up an mail server I personally use the following tools:

    - DKIM Validator (to test DKIM, SPF, Spamscore, ...)

    - Mail-Tester (same like above, but has a daily limit, so only to verify the result above)

    - SSL-Tools Cert / SSL (to check if SSL certs are set correctly)

    - MxToolbox (MX lookup and then SMTP test to check SMTP connection, you can also check openrelay and so on - best tool out there!)

    - SPF Record (If you dont know what it is, please google it - very importent setting)

    - Port25 (send mail and receive all information like spamscore, skim, spf, ... )


    All links can be found here: Useful tools and links

    First of all thank you very much Athar ! I was able to compile it but only with step 2 (by commenting out the patch 0029). I did not need to set the environment variable. It also seems that it is compatible with this script. I updated the first post.