Change PHP version

Changing the PHP version on your web host is usually risk-free, but can cause problems if your website code uses PHP features that are no longer supported by the new PHP version. We therefore recommend that you review your websites code before updating to ensure that it is compatible with the PHP version you wish to change to. Should the website not be compatible with your websites program code and go down after the change, you can easily switch back to the previous version again.

Change PHP version in DirectAdmin

Warning! The update takes place immediately and affects **all websites** hosted on the same web host, but is individually set for each user for Retailers.

Log in to Directadmin. If you are not sure how to get here, you can look in this guide.

Then navigate to Extra Features ⮕ Select PHP version inside DirectAdmin.

installatron1.png

To change the PHP version, select the desired PHP version in the list to the right of Current PHP version. When you have selected the desired version, then click on the text Set as current that appears to the right of the version list.

DirectAdmin Select PHP version selection

DirectAdmin Select PHP version selection

Dont forget to press Set as current after selecting a new version.

# Specify PHP version for individual websites

OIf you do not have the opportunity to change the global PHP version on your web host for various reasons, you can instead specify which PHP version should be used for a specific website by entering a code snippet in its . htaccess file. You must put this code snippet on all the web pages that you want to use a different PHP version than the global one set in DirectAdmin.

To edit your .htaccess file, you can connect to your hosting using an FTP program or go to File Manager inside DirectAdmin.

installatron2.png

Then navigate to /domains/domännamn.se/public_html/. Double-click the .htaccess file to edit it.

File Manager htaccess

For the Bas package

At the top of your .htaccess file you must enter the code snippet below. To specify which version to use, change x-lsphp74 to the desired version. For example, if you type x-lsphp80, you specify that the PHP version 8.0 should be used.

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

For the Prime packages

At the top of your .htaccess file, enter the code snippet below. To specify which version to use, change x-lsphp74 to the desired version. For example, if you type x-lsphp80, you specify that the PHP version 8.0 should be used.

AddType application/x-lsphp74 .php5 .php4 .php .php3 .php2 .phtml