How To Set Php Version In .htaccess
The PHP version is of import non only for speed and performance. At that place are different applications, which sometimes may crave specific PHP versions. With FastComet, all shared hosting clients can set specific PHP versions for different directories. For example, if yous desire to run PHP vii.4 on your business relationship, merely you accept to set PHP 7.two because of your specific application requirements, you can do that by setting custom rules for each of your folders. In this post, we volition explain how to run multiple PHP versions on the very same account.
How to Change the PHP Version for your Account
By default, all our Shared Hosting servers run PHP vii.ii as the native PHP version. With time, scripts may discontinue supporting this version of PHP, and thus clients need to have the option to run a newer PHP version on their accounts. If you merely want to modify the version of PHP site-wide y'all can follow the steps of our step-past-stride tutorial.
Run across also our guide on how to change your PHP version via SSH.
Choosing a PHP Version for a Specific Directory
You can use any combination of different PHP versions running simultaneously in any directory on the account. While this is non available using the PHP Selector UI, it is fairly elementary to do manually.
To prepare a different PHP version from the 1 assigned to your domain on your cPanel account, you demand to add together a special code to your .htaccess file. The .htaccess file is a hidden file that is read by the webserver. The spider web server follows any instructions independent within the file. For the purposes of this article, we will explain accessing it through the File Manager on the cPanel of your hosting account.
Navigate to the section Files → File Manager. If you lot wish to edit .htaccess file for your primary domain, navigate to the public_html binder. In case you demand to brand some changes to an addon domain, get to public_html/youraddondomain.com binder.
Once you are in the File Managing director, make sure that you have "Bear witness hidden files" enabled:
This way, y'all will be able to encounter "dot" files, which are unremarkably hidden by default. The specific file you need in that instance is the .htaccess file.
To ready a custom PHP version for your desired directory, either select the .htaccess file and click on Edit from the toolbar, or right-click over information technology and choose the option to Edit the file:
A pop-upwards window will appear, where once over again y'all demand to click on Edit:
Available PHP Handlers
Now that you lot are inside the .htaccess file, аt the pinnacle of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler. Depending on your desired PHP version for your specific application (folder), add one of the following lines:
For PHP 5.6:
AddHandler application/ten-httpd-php56 .php .php5
For PHP 7.0:
AddHandler application/10-httpd-php70 .php .php5
For PHP 7.1:
AddHandler awarding/x-httpd-php71 .php .php5
For PHP 7.ii:
AddHandler application/x-httpd-php72 .php .php5
For PHP 7.3:
AddHandler application/10-httpd-php73 .php .php5
For PHP 7.4:
AddHandler awarding/x-httpd-php74 .php .php5
For PHP eight.0:
AddHandler application/ten-httpd-php80 .php .php5
For PHP 8.1:
AddHandler application/ten-httpd-php81 .php .php5
Keep in mind that those lines are only for FastCloud and FastCloud Plus clients. If you are using our FastCloud Extra plan, your improver to the .htaccess file needs to be a bit different.
For customers using our FastCloud Actress packages, delight use the following snippet in your .htaccess file:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp<phpversion> </FilesMatch>
The actual change is fabricated past switching the SetHandler line with one of these depending on the version (look at the last 2 digits):
- SetHandler application/x-lsphp56
- SetHandler application/x-lsphp70
- SetHandler awarding/x-lsphp71
- SetHandler application/ten-lsphp72
- SetHandler application/ten-lsphp73
- SetHandler application/x-lsphp74
- SetHandler application/x-lsphp80
- SetHandler application/x-lsphp81
Later on you have added your own configuration rules, save your changes and close the .htaccess file. Now y'all should take your custom PHP version set.
If you have difficulty with the PHP settings of your hosting business relationship, practise not hesitate to contact the FastComet technical back up team.
Nosotros hope you find this commodity useful. Observe more nigh FastCloud - the elevation-rated Hosting Solutions for personal and minor business websites in four consecutive years by the HostAdvice Community!
Source: https://www.fastcomet.com/kb/how-to-set-custom-php-version-per-directory

0 Response to "How To Set Php Version In .htaccess"
Post a Comment