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 ?
Question posted in PHP Versions
You can find a list of all versions here.
You can find a list of all versions here.
2
Answers
You can use as many different versions as you want.
Consider:
Install PHP versios with PHP-FPM
Create directory strucure for each version (website)
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
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:The example above is for PHP 8.1.