How to change the PHP version my web server uses
Disclaimer: before attempting to update the PHP version of your website we would highly recommend that you make a full backup of it, just in case anything goes wrong.
First determine which of the following web hosting scenarios best applies to your website:
- The website uses shared hosting that is managed by my hosting provider: If your website is hosted by a good web provider then making the switch should be a quick and pretty painless procedure. It's very likely you will be able to make the change yourself via a 'control panel' interface that you've been provided with.
- The website runs on a VPS or custom server I have to manage myself: If you have hosting that is 'un-managed' (many Virtual Private Server solutions are provided without support for updates) then you may have to undertake the PHP upgrade yourself.
Let's now look at these two options in more detail...
Updating PHP on a typical 'fully managed' shared hosting package
Please note that exactly what options are available to you to change the configuration of your server will depend completely on the web host and product you are using.
Ideally you would have access to a website control panel that you can use to alter the PHP version used to run your website. This process has some prerequisites:
- You are happy to undertake this task yourself. Changing your PHP version should ideally not be done on a live website in case the new version causes incompatibility issues with your website code. See our article on how to test your website with a new version of PHP here.
If your website isn't yet public or you don't mind some down-time you can quickly make the change and test 'live'. If you encounter a problem, revert back to the previous PHP version. Now look at our guide troubleshooting errors having upgraded PHP.
If that isn't an option however you will need to create a copy of your website to test on. If you don't know how to backup your website and create a copy this whole process is likely not for you. In this case you probably want to find a developer to help you.
- Even if your ISP supports changing your website's PHP version, they may not have a web admin to configure this from. You may have to do it via a configuration file such as within the .htaccess file. If you cannot find any reference to managing the PHP version of your web server inside the control panel interface you probably want to check their support website. There is likely a knowledge base article about this and if still no joy we would recommend that you raise a ticket with the support department.
- You may discover that your web provider simply doesn't offer the latest PHP on your particular hosting package.
You may be able to resolve this by migrating to a new server at the same provider as sometimes old accounts get stuck on legacy hardware that don't receive the same level of maintenance. However, it may well be possible that your provider simply doesn't offer the version of PHP that you want. If they are unable to support current versions you may want to consider moving to another ISP.
Assuming that you do have access to a control panel to change your PHP version read our tips for changing PHP via a control panel here.
Updating PHP on an 'un-managed' web server that you have responsibility for maintaining
This process depends largely on what kind of operating system your web server runs on. Pick the guide that relates to your setup:
My ISP doesn't offer the version of PHP I need
You may conclude that you need to move your website to a new ISP. Follow our guide on moving to a better PHP host here.
I built my own server, what are my options?
Start here with our guide on how to manually upgrade PHP here.
Do these steps sound too complex or time consuming?
It sounds like it's time to call in the professionals. Check out our guide to PHP developers that can assist.
Article last updated: 21st January, 2021