Home > Net >  Use different php version in dedicated server folders?
Use different php version in dedicated server folders?

Time:08-26

I have dedicated server on godaddy.com which have a domain named example.com in this domain i have two backends one CodeIgniter which use PHP 7.4 and another Laravel 9 which required PHP 8.0 so my cPanel still using default PHP 7.4. Is there a way to make the folder contain Laravel 9 use PHP 8 instead of cPanel defaults version 7.4 which i don't want to change ?

CodePudding user response:

cPanel has a feature called Multi-PHP, which does what you need (if your host has it enabled).

For each project, it puts a snippet like this in the .htaccess which sets the PHP version to use:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

The example above is for PHP 8.1.

CodePudding user response:

You can use as many different versions as you want. Consider:

  1. Install PHP versios with PHP-FPM

  2. Create directory strucure for each version (website)

  3. Configure Apache for Both Websites.

With the above configuration you have combined virtual hosts and PHP-FPM to serve multiple websites and multiple versions of PHP on a single server. The only practical limit on the number of PHP sites and PHP versions that your Apache service can handle is the processing power of your instance.

There is a step by step guide here :Multiple PHP version on one server

  • Related