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 ?
2 Answers
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.

- 15,992
- 7
- 69
- 116
-
Is this for root .htaccess or need to create it inside laravel 9 directory ? – Q8Xbox Aug 25 '22 at 23:24
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

- 2,141
- 1
- 6
- 17
-
This answer will not work because the questioner says they are using cPanel. – Moshe Katz Aug 25 '22 at 22:55
-