There was a problem loading the comments.

How to setup PHP for my domain and subdomains on cPanel

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

IndicHosts.net provides multiple PHP versions ranging from PHP version 4.4.xxx to PHP 8.1.xxx to use with your domain and website. Linux web hosting is built on cPanel or DirectAdmin GUI control panels. If you are using cPanel as your Control Panel, for each version of PHP (say 8.1) we further provide two types of PHP namely ea-php and alt-php;

 

  • ea-php is the default version of PHP provided through cPanel which is based on the publicly available PHP open source repository. ea-php is the recommended version of PHP to be used with your website , if you decide to use PHP-FPM as the php handler for your website.

  • alt-php is the commercial version of secured PHP with security fixes and updates, applied to PHP open source repository versions. alt-php is the recommended version of PHP to be used with your website, if your website requires an outdated version of PHP which is no longer supported by the PHP open source repository.  


Tools for Setup of PHP environment of your website: We provide following tools namely "MultiPHP Manager", "MultiPHP INI Editor" and PHP Selector (or "Select PHP version") to setup the PHP version, handler, extensions and variables for your domains. These tools have specific functions and needs to be used accordingly;


  • MultiPHP Manager
    is the interface tool for choosing an ea-php version PHP 8.0.xxx to PHP 8.2.xxx (supported PHP versions as on date of writing the article supported by php.net). MultiPHP manager is the only interface to be used in case you wish to use PHP-FPM (FastCGI Process Manager) as your php handler for your website's PHP. PHP-FPM is only supported on ea-php on our servers.


  • MultiPHP INI Editor
    is the interface tool to configure custom PHP extensions, variables and settings for ea-php, if ea-php is selected for use with your website in the MultiPHP Manager (as explained above). You can enable/disable php extensions and/or define custom PHP variables per directory under public_html, for the ea-php version deployed on your domain.


  • Select PHP Version
    or "PHP Selector" as it is commonly known, is the interface tool to be used if you decide to use commercial hardened, secured PHP version 4.4.xxx to PHP 8.2.xxx with your with Mod_LSAPI Pro as the php handler.

    If in doubt, IndicHosts.net recommends using alt-php to power your domains as;
    • alt-php versions are supported (secured and hardened) for years beyond the official End Of Life date of the php version.
    • alt-php versions will-not be removed from server once the End Of LIfe date is reached for that PHP version whereas ea-php versions will be removed from server as soon as End Of Life date is reached for that PHP version, forcing your script to switch to a supported PHP version.    

 

How to use Select PHP Version or "PHP Selector" to setup PHP versions, extensions, handler and variables for your domains?

    1. Step 1: To enable the "PHP Selector" goto MultiPHP Manager and set the domain, subdomains to use PHP version "inherit". Please note this is a mandatory requirement, without which the PHP selector will not function. Setting the PHP version to inherit tells the Control Panel to disable ea-PHP and enable alt-PHP on your domain.



    2. Step 2: Goto Select PHP Version or "PHP Selector", set "Current PHP Version" to any version other than the "native" version.  This tells the Control Panel that you would like to setup extensions, variables in your PHP environment different from the default-setup of extensions, variables in the selected PHP version. IndicHosts.net recommends that you select any PHP version other than the "native" version for your website.



    3. Step 3: Goto Extensions tab of Select PHP Version or "PHP Selector" & select the PHP extensions of you choice. You can enable or disable them by clicking the box next to the extension name.



    4. Step 4: Goto Options tab of Select PHP Version or "PHP Selector" and modify the PHP variable, options as required for your website. Listed here are the most commonly used PHP variables and options, that clients want to modify for their domains. If you need any other PHP variable or option modified, which is not available on this page, you can setup that variable using the MultiPHP INI Editor or get in touch with us to set it up for you.



    5. Step 5: Add a phpinfo() php file to your domain root to verify the correct PHP environment has been set up for your domain. The code to added in file is given below;

       

      <?php phpinfo(); ?>

       

      Then try to access the php file in your browser to see the PHP environment information as given below. Sometimes as a security measure, the function phpinfo maybe disabled in your PHP environment and the phpinfo data may not render in browser. If this happens, you can remove the phpinfo function from disable_functions option in PHP Selector >> Options Tab >> disable_functions and then try to load the file in browser.




How to enable PHP-FPM as php handler for your domain?

PHP-FPM or FastCGI Process Manager is an advanced, highly-efficient processor for the PHP scripting language. WordPress websites configured to use PHP-FPM can handle higher amounts of website traffic while using fewer server resources than other PHP handlers. PHP-FPM dramatically speeds up the performance of your PHP environment compared to traditional PHP handlers like DSO, CGI and suPHP. However compared to alt-php's Mod-LSAPI Pro, the website speed difference is marginal. Here are simple steps to enable PHP-FPM on yoru domain;

  • Step 1: Goto MultiPHP Manager and select an ea-php version to power your domain.

  • Step 2: Raise a support ticket and request us that PHP-FPM to be enabled on the domain.

  • Step 3: Visit the MultiPHP INI Manager and setup the custom extensions, variables for your domain

  • Step 4: Visit your phpinfo() page and verify that PHP-FPM is enabled on your domain


How to Setup a subdomain or addon domain to use a different version of PHP that the primary domain?

Clients at times use different scripts on subdomain which required a separate PHP environment setup, different from primary domain's PHP environment. The difference could be in the  PHP version, handler, extensions and/or variables. We recommend such sub-domains be deployed as a separate cPanel account, for easy of use and management. However, if a separate cPanel account is a constraint, advanced website developers, administrators can achieve a completely separate PHP setup for a subdomain. Let's see how to do this;

 

Steps to setup different PHP versions per directories or subdomain using alt-php with mod_lsapi 

    1. Step 1: Goto to the http root of the subdomain create a .htaccess file in the desired directory where you want to have a different from default PHP version with the right handler with the following commands

        1. To load a different ea-php version:

          <FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
          SetHandler application/x-httpd-ea-php80-lsphp
          </FilesMatch>

           

        2. To load a different alt-php version:

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

          Please change the php71 to the version number you need.

          Note! If you have a non-native version selected for the primary domain. In that case, if the version that you assign through .htaccess is the same as ea-php version selected as the system default version, that version will not be applied, the version that you'll actually get will be the same as selected in PHP Selector.

           
    2. Step 2: To modify the default PHP extensions, variables, options for the custom PHP version applied to subdomain, subdirectory above, use the MultiPHP INI Editor to setup a custom php.ini for the subdomain or subdirectory.

    3. Step 3: Visit your phpinfo() page and verify that PHP-FPM is enabled on your domain 
         

Steps to setup different PHP versions per subdomain using ea-php with suPHP or PHP-FPM

    1. Step 1: To enable ea-php on a subdomain goto MultiPHP Manager and enable ea-php version on the subdomain.

    2. Step 2: Visit your phpinfo() page and verify that ea-php is enabled on the sub-domain.

    3. Step 3: Make a ticket and ask us to enable PHP-FPM on the sub-domain.  

 

Steps to setup different PHP versions per subdirectory using ea-php with suPHP

    1. Step 1: Create a .htaccess file in the subdirectory and add the following code;

       

      # php -- BEGIN cPanel-generated handler, do not edit
      <IfModule mime_module>
        AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
      </IfModule>
      # php -- END cPanel-generated handler, do not edit

      You can change the term php81 above to any other version of ea-php available on server such as php80 or php82 or php74
    2. Step 2: Visit your phpinfo() page and verify that ea-php is enabled on the sub-domain.


Note: Current enabling PHP-FPM on a sub-directory with mapping a sub-domain or addon domain to it is not supported.


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net