-->

Using multiple versions of PHP on the same host

    Are you running multiple blogs / websites at the same time? Does each of your blogs / websites only support a certain version of PHP? In case you want to run PHP 7.x on one site but still want to keep PHP 5.x on another site, what should you do? You may not notice, many current hosting providers have allowed this to be done easily via cPanel. Yes, you can use multiple versions of PHP on the same host, each domain has a different version of PHP.
    Right after this, I will show you how to set up a separate PHP version for each domain. Of course, in case your cPanel has support.

    When the host supports using multiple versions of PHP at the same time

    Change the PHP version for each domain

    1. First, you need to access cPanel of the hosting you are using. Find out if there is a MultiPHP Manager section If so, click on it.
    Click-on-muc-multiphp-manager
    2. In the MultiPHP Manager interface , check the domain name you want to change the PHP version, then select the PHP version in the PHP Version section . Click the Apply button to confirm.
    ban-cho-phien-php-cho-tung-domain
    3. Wait a moment for the process to complete. Reload the browser tab, you will see PHP version of the domain has been changed.
    publicity

    Change the setting of the PHP version

    4. Now it's time to customize the settings for your chosen PHP version. Return to the main interface of cPanel, find the MultiPHP INI Editor and click on it.
    Click-on-muc-multiphp-ini-editor
    5. There are 2 modes to edit PHP settings: Basic Mode with simple interface, easy to use but few parameters to customize. Editor Mode requires a specialized knowledge of PHP but allows more customization.
    • With Basic Mode , you just select the domain name then turn on / off or edit the parameters and then click the Apply button .
    basic-mode-php-o-basic-mode
    • With Editor Mode , you must add the following lines of code to the custom PHP parameters via php.in file That's why I said you need to have an in-depth knowledge of PHP.
    editor-mode-php-o-editor-mode
    Click the Save button to save when finished.

    When the host does not support using multiple versions of PHP at the same time

    Don't worry, add the following code to the end of the file .htaccessin the domain's root directory:
    < FilesMatch "\. ( Php4 | php5 | php3 | php2 | php | phtml) $">
    SetHandler application / x-httpd-alt-php71 ___ lsphp
    </ FilesMatch >
    view raw.htaccess hosted with ❤ by GitHub
    Remember to replace it php71with whatever PHP version you want (of course it must be hosted by the host, see the list in Select PHP Version ). For example, if you want to use PHP 7.3, replace it php71with php73.
    In addition, you can also use the following code to replace in case the above code does not work:
    < IfModule mime_module>
    AddHandler application / x-httpd-ea-php56 .php .php5 .phtml
    </ IfModule >
    view raw.htaccess hosted with ❤ by GitHub
    Of course, don't forget to replace it ea-php56with the code of the corresponding PHP version you want to use.
    As for customizing the module or parameters of PHP, you can do it through the Select PHP Version feature of cPanel:
    select-php-version
    That's all you need to do to use multiple versions of PHP on one host at a time, each domain running its own version of PHP. It's not too complicated, is it? Good luck!

    No comments