Home ยป Change php version of wordpress website

Change php version of wordpress website

How to upgrade the php version for your website

One of the most important things you need to do to keep your WordPress blog functioning well is to use the latest versions of WordPress and php. Upgrading your php version is easy and can be done through the cpanel or WHM. Almost all hosting companies now offer the option to upgrade to php version 8 or above. Upgrading to the latest php version is also important from a security viewpoint. All that you need to change your version of php is access to Cpanel or WHM.

Login to your cpanel and search for the Multiphp manager which can be found in the software section. Click on Multiphp manager and open. Here you will find the list of domains and subdomains. Select the domain that you want to upgrade your php version for by clicking inside the checkbox. On the right hand side, select the php version that you want to upgrade to and click apply.

A popup will inform you that the change was successful. Now, since php 8.2 is available, you can switch to the latest version. Once, you have changed the php version, just go to your blog and check out if everything is functioning well and there are no conflicts. check the front end as well as the admin panel for any visible issues. To check if the editor is working fine, select any post and click on edit and take a look. If everything looks fine at the back end, try reloading your blog a few times in incognito mode.
If there is no issue, your change has been successful. If you see any trouble, you can switch back to the previous version using the same process and then find the source of conflict. Before you change your php version, you must also check if you are using the latest version of wordpress and upgrade if not. Do take a backup before upgrading wordpress, which will make it easier for you to use the latest version of php.
In case, you are running more than one blogs on the server, you can also change the php version for all your blogs by selecting a default php version or changing the php version for all your blogs from the same location. You will see there is an option apart from the available php versions named ‘inherit’. When you select inherit, the apache server uses the first .htaccess file that it finds in the domain’s file structure. If it cannot find an .htaccess file, it uses the default version you have set for the system. Each new domain that you add to the server has the default version enabled by default.
To achieve this you need access to the WHM. Login to the WHM as a root user and then go to the multiphp manager.
Search for multiphp manager in the search box on the left or go to the software section in the WHM where you will find the multiphp manager. You may also find it easier and safer to select your php version from the WHM compared to other methods like adding handlers to .htaccess file.

Once you are inside the multiphp manager in the WHM, you can set the default php version under system settings. Remember, this will apply only to new domains or the domains which have the inherit option for php version enabled. So, it will not automatically apply to the domains you already have in your account. However, setting the php version for individual domains is possible from here. Just click on “user domain settings” beside the “system settings”.

You will find a list of all the domains and subdomains hosted on your server here. One by one, you can change the php versions under the PHP version column. Select the right php version and the system applies it. You can also change the php versions for all domains and subdomains at once from the multiphp manager. Select all the domains and subdomains using the checkbox on top left. Now, you can set the php version from the dropdown list or set them all to inherit the default php version. That’s all and now you can exit the WHM.
If you have multiple websites hosted on the same server, upgrade the php version on one of them first through the cpanel. If the change is successful, you can apply it to all through WHM. In case, any of your sites stops functioning after upgrading the php version, you can change to the previously used php version and then identify any conflicts.
Switching to the latest php version can be good for your website’s performance and security.

How to install php 8.2 in WHM

If you want to switch to a php version that is still not available in your account then you will need to add that version. For example, you might have php 8.1 and related extensions in your account but not php 8.2. Php 8.2 was released in December 2022. So, you will need to add php 8,2 manually before you can change the php version to 8.2. To add it login to WHM and search for easy apache 4. When you click on it, you will be taken to the profiles page and you can check the current profile if it has php 8.2 included. If it has php 8.2 included, you can install it by customizing the profile and then provisioning. If the currently installed package does not include php 8.2,then check out the other listed packages and select the one with the latest versions like 8, 8.1 and 8.2. You can then customize that package and provision it. In case, you want to remove and older php version from your account, you can also uninstall it from here. For example, you can remove php 7.4 safely from here and keep only php 8, php 8.1 and php 8.2.

You can also select the related php extensions from Easy Apache 4 and install the ones you need. The package must automatically include the necessary php extensions. However, you should check and if you want any extension that is not installed currently, you can install them from php extensions. Check the list of php extensions to see which ones you want. For example, php82-php-opcache extension or Zend Opcache and other extensions like exif, intl or php-fpm and php-fileinfo. Once done, click on review and then provision. Once the provisioning process has completed, you can go back to the multiphp manager and then to system settings and user settings. Under the system settings, you will now find php 8.2 in the dropdown and you can select it as default or just leave it and move to user settings. If you have more than one sites hosted on the same server, you can change the php versions for each from the user settings and also toggle php-fpm on or off. PHP FPM offers some great performance improvements and especially if you have NGINX reverse proxy enabled. When you use NGINX with php fpm, memory consumption is significantly better.