In this article we'll present a brief guide on how to transfer website hosting. We'll focus on the most popular website hosting platform for Small Businesses: Linux Apache MySQL PHP - LAMP. Before proceeding to read on how to move a website from one host to another we strongly suggest reading our article on how to find the best provider of website hosting
- Identifying the type of the web hosting of your old provider
- Checking for compatibility issues and selecting a suitable destination
- MySQL Export job
- Exporting Website File Structure
- Importing MySQL database
- Importing Website Files
- Adapting configuration files
- Tests, troubleshooting
- Point the domain name to the new IP address (DNS switch)
Identifying the type of web hosting of your old provider
There are several mainstream website hosting systems that automate deployment and management tasks for hosting. CPanel, VirtualMin, Plesk are mainstream hosting systems compared here
. If you choose a destination web-host that matches the old one it would fold steps 3-6 into a simple two-step procedure of Export -> Import. It's also possible to hop from one to another, for example VirtualMin is capable of importing packages created by CPanel and Plesk. It's also possible NOT to rely on any particular hosting system administered by a Web interface and migrate a website without any automation and web-management tools.
Checking for compatibility issues and selecting a suitable destination
This step is crucially important because your website simply won't operate if the versions of PHP, MySQL or Apache are not compatible with its code. For example, a lot of websites rely on certain Apache modules and PHP's PEAR libraries in order to save time, money and utilize pre-cooked solutions for common needs such as sending Emails, Encryption, Authentication, etc. Very often it's necessary to have a close match of versions and parameters in order to transfer website hosting. It's safe to claim that the destination web-hosting platform should provide all components that your websites relies on AND their versions should be the same or newer. A leap to environment running much newer software could also lead to serious problems. Apache, Apache Modules, PHP, PHP PEAR and MySQL need to be checked in the first place:
- PHP + Apache (with modules) - create a file "hosting-versions.php" with this content "
<?php phpinfo() ?>" , upload it to the server and point your browser to this URL: http://your.domain.com/hosting-versions.php The page will display all necessary information.
- PHP PEAR - use this shell command: pear list (there might be other ways to look it up, for instance via Cpanel). Web-based approach is more complicated and discussed here
- MySQL - via shell: mysql client (CLI) would simply show it upon logging in; other web-based alternatives like PhpMyAdmin are introduced here
When it comes to "popular" annoyances with MySQL databases - 'collation' and 'character set' issues are the top offenders. It is best to ensure that the destination database matches the original values.
MySQL Export job
Two popular routes here:
- PhpMyAdmin web-interface which would fit most scenarios.
- Shell command: mysqldump which would allow heavy customization
We'd want to compress the output because it'd seriously shrink the file.
Exporting Website File Structure
Any compression utility like ZIP or TAR with Gzip would work just fine.
Importing MySQL database
As we mentioned earlier it's important to pay attention to 'collation' and 'character set' parameters when creating a new database to run an import job. It's best to use the same tool to run an import job as was used for exporting the database. Aka MyPhpAdmin Export -> MyPhpAdmin Import. You'd need to create a user / password and grant privileges to the newly imported database. If it's possible to preserve the original database name, user name, and password it might eliminate any need to adapt configuration files and save time.
Importing Website File Structure
Usually you'd use an FTP method of uploading a compressed file onto a new server. We'd strongly advice to check and adjust for proper ownership and permissions after unzipping the archive.
Adapting configuration files
It's quite possible that transferring website hosting is arranged in such a way that no changes are needed. MySQL connection parameters are the same, all PHP / Apache parameters are closely matching the origin and all stars are aligned just right. Sometimes it's not the case and a number of updates are needed - MySQL connection, Paths to local libraries, etc.
This stage may consume 99% of all efforts needed to move a website from one host to another. If you see that your website is not performing the way it should then here's a list of potential troublemakers:
- file permissions
- wrong configuration parameters
- different settings of PHP, Apache modules, MySQL
- missing prerequisites - libraries and modules of required versions
- interference by security protection utilities (firewall, Apache's mod_security, etc)
- limits of system resources available (memory, storage, CPU cycles)
In some (rare) cases a web hosting firm would provide a knowledgeable and willing engineer who'd help with these issues, in others one would need to request some help from an experienced IT consultant
Point the domain name to the new IP address (DNS switch)
This is the easiest part provided that you're in control of your domain
. At this point the web hosting company provided a new IP address of your website during the transfer and you'd point an (A) record for your domain name to the new address.
At last we should mention migration of website statistics. It's not overly complicated with popular engines like Webalizer and Awstats. CPanel -> CPanel or VirtualMin -> VirtualMin would simply handle it out of the box. In case with Google Analytics
nothing needs to be done since all data is kept on Google's side or any other 3rd-party cloud provider.