Custom php version per directory/folder

Discussion in 'Installation/Configuration' started by Coda, Sep 27, 2023.

  1. Coda

    Coda New Member

    Hi all, I'm looking for a solution for custom php versions per directory/folder to override the default php version set for the site/domain, e.g. Default php version 8.1 Custom php version 7.4

    I found a lot of solutions for overriding the default php version in a directory/folder, but none of them worked for my ISPConfig server. One of the solutions is as follows:

    <FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
    SetHandler application/x-httpd-alt-phpXX___lsphp

    phpXX (phpversion, like php74)
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    You should enable, then use vhost for sub / alias domain instead but do specify the folder during its setup.
  3. Coda

    Coda New Member

    Hi ahrasis,
    Could you please explain this a bit more? A step by step guide if possible.
  4. michelangelo

    michelangelo Active Member

    That's afaik - at least via ISPConfig - not possible at the moment.
    You would have to configure a separate FPM pool manually for the PHP version that you want to serve in that subdirectory.
    You can use as a FPM pool template a copy of the main PHP-FPM pool config that was assigned via ISPConfig for the webspace.

    After setting this FPM pool manually up you need to add the required Apache directive in ISPConfig (haven't tested it, just guessing how it may work):

  5. chief

    chief Member HowtoForge Supporter

    this should allow you to have multiple versions of php on each domain
    you could using subdomain - try a link on page 1 (php8.2) display a link to subdomain (php7.2) and make it up by that
    separate entities, linking back and forth.
  6. Coda

    Coda New Member

    Hi michelangelo,

    Thanks for your guidance. I have zero experience with manually configuring separate FPM pools, but I'm willing to learn and let you know the final results later.
  7. Coda

    Coda New Member

    Hi chief,
    Thanks for your time. The solution above looks more like using multiple php versions on the server rather than on the domain.

    When using ISPConfig, by default, you only have the main PHP version for your distribution. This guide will take you through installing additional PHP versions (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.1, and 8.2) on a Debian server with ISPConfig. A similar guide is available for Ubuntu systems, which can be found here. "
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    You can not have multiple PHP versions per domain without having multiple PHP versions installed on the server. So the first step is always to install multiple PHP versions as shown in the guide.
    ahrasis likes this.
  9. Coda

    Coda New Member

    Hi till,
    Thanks for that.
    Sorry everyone, I forgot to tell you that multiple php versions from 5.6 to 8.x are installed during the server installation.

Share This Page