× PHP Version Test Update PHP Help & FAQs Get PHP Version Notifications Find a PHP Developer
PHP expiry alert : PHP v7.4 has recently expired. Is your website still running this version? Click here for more details
SAFE versions of PHP: 8.2.6, 8.1.19, 8.0.28

How to migrate a PHP website to a new web server / web host

So you have determined that you need to migrate ISP as your existing provider doesn't offer a compelling current version of PHP. The process of migrating the website to a new hosting environment is summarised below and aims to cover all the key steps that you will need to undertake.

Please ensure you read this fully before you attempt to actually start a migration. As already mentioned, this is only a summary guide and your actual migration may be able to skip some of the steps we list if not relevant. It may also be the case that you need to undertake some additional steps to get your website working at its new web server.

Preparation

  1. Clarify where you are going to migrate to - the first step in the process is to naturally find a suitable replacement server or internet service provider (ISP). Make sure that the new ISP doesn't just support currently maintained PHP but that it also supports anything else specific that your website may require.

    This may be anything from a particular technology such as a caching or memory management system (for example reddis) to a program installed on the server that your website needs to make use of. For example ffmpeg (a video encoding tool).

    It's also worth checking if the new provider supports the latest security standards and maybe they even offer free ssl certificates through a service such as Let's Encrypt. If you have business requirements maybe you need PCI DSS certification?

    If you aren't 100% sure about what your website needs to run contact the people who made it to clarify. If still uncertain you could in theory still proceed with the transfer and then just test the new hidden copy of your website to see if any issues appear.

  2. Backup your existing site : website files (step 1/2) - It is VITAL that you first backup your existing website on the original provider and keep a safe copy of these backup files. Your website likely comes with a visual customer management portal through which you can browse files on the web server. Hopefully this will allow you to create a single ZIP file of the entire website. Make sure that you back up the entire structure. Your website may just reside under a public folder where the root of the website is visible. However other websites for security reasons hide some of their files outside (above) this public root folder. If you are not sure what needs backing up ask the developer of your website.

    This backup will not just be for creating a safe fallback should anything go wrong but these files are going to be what you transfer to the new hosting in the following step of this guide.

  3. Backup your existing site : database (step 2/2) - Your website will likely have a database that holds most of its content and settings. Not all websites need a database to run however and if yours doesn't then you can naturally skip this step.

    If you do have a database/s running your website login to your customer management portal and you should find an option there to backup and download a live snapshot of the database.

    If your website has functionality that lets users add content themselves it is very likely that you will need to plan exactly when this backup should be made. The normal answer is as close to the point of transfer as possible. This is simply because making a backup some hours/days before the actual transfer runs the risk of the database extract being out of date as soon as it's made. The result of installing that copy on the new server would be the sudden loss of any data created/edited after the point the backup was made when you make the switch to turn the new server on.

    We'd recommend that you make a clear note of your existing database server version at this point and then compare it to the version your new hosting will have. A big jump in version may result in import issues later in the import process. If you are unsure how to do this your providers will be able to clarify for you.



Copying the website

  1. Copy the files - Copy the zip of your website files up to your new hosting account. You will likely be able to do this either via a visual web based interface or via a transfer system such as FTP/SFTP.

  2. Import your database - the process for installing the backup of your database (likely a .zip file or .sql text file) on the new web server should also be possible via a web based interface. The details of this are quite variable depending on your hosting platform so we won't go into further specifics. If however you are unsure how to do this raise a ticket with your new ISP who should be able to assist.



Post copy tasks

  1. Permissions - If your website needs to be able to create/update/delete files (maybe users can upload images for example) then you may well need to set specific file permissions on some folders in the website file structure.

  2. Did the url change? - If for some reason the web address/domain of your website has changed during the migration you may well need to now update various settings. These may be stored in configuration files or in database records. WordPress for example is famously tricky regarding this as it writes the full web url of a post into each record of its database. So you'd need to update all these records in the event of a new url.


Ready to go live? Not so fast...

Before you undertake the final step which is to updating your DNS so that it points to your new ISP's web server (contact your new ISP if any queries on what you need to change in your DNS) it is vital that you test, test and test again!

There is always the possibility that migrating your site to new hosting may cause it to break because of changes to the PHP language and your website now using unsupported (depreciated) functionality.
Article last updated: 12th May, 2021