You can easily update your PHP version. This is done through the PHP selector in DirectAdmin, where you can choose from all versions currently supported by the PHP developers. Each new version makes PHP more stable, faster, and more secure.
To ensure your website runs at its best, it is important to use the most recent PHP version if your website supports it. This guide will show you step by step how to update your PHP version.
Changing the PHP version via the PHP selector
1. Log in to DirectAdmin.
2. In the menu, go to 'Extra Features' → 'Select PHP version'.
3. Select the desired PHP version from the drop-down menu under 'Current PHP version'.
4. Click 'Apply' to implement the change.
5. You have now successfully changed the PHP version. You can always switch back to a different version the same way.
Please note that this change applies to all websites on your web hosting package. If you want to change the PHP version for a specific website only, you can do so via the .htaccess file. This method is explained in the next section.
Via the .htaccess file
Using the PHP selector to change the PHP version applies to all websites on your hosting package. Sometimes, however, you may want this change to apply only to a specific website. For example, because not every site in the package is compatible with the newer PHP version yet.
In that case, adjusting the PHP version via the .htaccess file offers a solution. With it, you can set the PHP version for a specific website. You do this by adding a line in the .htaccess file at the location where the website is hosted. Choose the line corresponding to the version you want to use.
PHP 8.0
AddType application/x-lsphp80 .php
PHP 8.1
AddType application/x-lsphp81 .php
PHP 8.2
AddType application/x-lsphp82 .php
The contents of that specific folder will then be handled by the PHP version you specify in the .htaccess file. Where needed, you can verify this with a phpinfo file.