You’re ready to make the move to managed hosting for your Magento or WordPress site. You have a new service at Nexcess, but how do you actually make the leap?
Keep reading to learn how to migrate your website from one host to another — in this case, from AWS to Nexcess fully managed hosting.
What is a Migration?
When we say “server migration” we mean copying or moving critical data from one server to another, and configuring that target server to replace the first. Server migrations in the web hosting world can involve setting up web server and database software, copying over websites and their configurations, and changing the DNS to direct visitors to that new server.
Server migrations are important in the lifecycle of your server, to ensure that the operating system and the hardware beneath it stay up to date with current technology, to economize and consolidate hosting, or to expand and distribute hosting to help reduce load at a single point.
How to Migrate Your Website to to Nexcess: The Easiest Way
End-to-end migration support is included at no extra cost with all managed hosting plans at Nexcess. If you want us to do all the heavy lifting for you, just ask! You can request a free migration from the Nexcess portal by providing the names of the domains to be transferred and their access credentials.
In most cases, migrations can be completed in a week or less. We provide the opportunity to test the migrated data after it is initially synced, and ask that you update DNS once the migration is complete. This will make your new hosting live. Beyond that, our experts have everything they need to accurately duplicate your websites to their new home.
There are some cases where you might want to perform your own manual migration. For instance, you may have a very strict time frame for leaving your old host, and can’t wait in line for the next migration technician to become available. Or, you may simply wish to have the experience of performing your own migration.
Whatever the case may be, these steps should help you migrate your websites from AWS, or anywhere else, over to Nexcess fully managed hosting.
Migrate to Nexcess for free
You shouldn’t have to work hard to migrate your site — that’s our job
How to Migrate Your Website Manually (for WordPress Users)
If you’re using WordPress, an easy way to migrate your CMS to Nexcess Cloud is to use our handy migration plugin. This plugin installs on your source site, and pulls all of the data needed directly into the target hosting account using FTP credentials you supply from the Nexcess control panel.
Click here for detailed instructions on how to migrate your WordPress website.
How to Migrate a Website from One Host to Another Manually in 8 Steps
Going to try it? Here are the steps needed to manually copy the files and database from ANY source vendor, with ANY supported CMS, to Nexcess Cloud.
For our example, we will be migrating a Magento site from AWS.
1. Before You Begin
The core of a migration is copying your site files and databases to the new site, and updating the DNS to direct traffic to the new location. This requires access to the files and database from your source (AWS in this case), and access to the correct location to put these files and database in Nexcess. You will also need a program to collect all of your site files and push them to the Nexcess host.
Assuming that you used Lightsail to install your Magento instance at AWS, you should be able to connect to your instance from your AWS dashboard, and use the terminal window in your browser.
Your Nexcess SFTP/SSH credentials are located in your plan dashboard as well. You will need to generate a new password if you have never connected to SFTP/SSH before on your cloud account. Record this somewhere safe.
As before, you will want to find out where DNS for your current site is hosted. These are the records that translate your domain name into an IP address, and we will update them at the end of the migration. You can generally find this out by looking at the NS records.
2. Connecting Your Machines
Now that you have your SSH credentials for both machines, they will need to be connected to each other to transfer data. There are multiple ways of accomplishing this, but the easiest way is to have the source (AWS) machine talk to the target (Nexcess) machine directly.
Your Nexcess Cloud has a variety of tools available from its SSH shell to accomplish this, including rsync, ssh, lftp, and scp. We will use a number of these commands to complete our migration.
First, we will connect the SSH to the AWS account. Follow these instructions from Amazon to connect to the web-based terminal for your server.
Now that we are on the source machine, we can use the one-line SSH command listed from your plan dashboard to get a shell on your target server:
ssh a009b438_1@8e47bb3054.nxcli.net “echo hello”
This string will ask you for your Nexcess user password. Once you enter it, the AWS machine will connect to the Nexcess Cloud server. Have it run the “echo hello” command (printing the word ‘hello’ to the terminal) and then exit the SSH session. If you see ‘hello’ then you’ve successfully authenticated, and we are ready to migrate!
3. Locating Data
Files on your AWS instance, assuming you used Lightsail’s Bitnami Magento install, will be at either /opt/bitnami/magento/ or /opt/bitnami/apps/magento/htdocs/ depending on the age of your server.
Once you have located your document root, you will also need to get the database connection information. This can be pulled from the Magento configuration file, like so:
Magento 1:
grep -e username -e password -e dbname \ /opt/bitnami/apps/magento/htdocs/app/etc/local.xml
Magento 2:
grep -e username -e password -e dbname \ /opt/bitnami/apps/magento/htdocs/app/etc/env.php
The terminal should now display the username, password, and database name for the Magento database. You can use these with the ‘mysql’ command line program to get into your database, replacing the example data as appropriate:
mysql -u aws_username -p"aws_password" aws_dbname
Now, you can type ‘show tables;’ and mysql should print a list of the tables on your database. Type ‘exit;’ to leave the mysql command line interface.
4. Copying Data
We know where our data is on AWS, so let’s put it into Nexcess Cloud. All of these commands will be run on the AWS terminal. Replace the example data in the commands to suit your installation.
First, we will make a temporary directory on the Nexcess server:
ssh a009b438_1@8e47bb3054.nxcli.net "mkdir migration"
Next, we will make a database dump and put it into this folder. This command avoids a local temporary file by dropping the output from the database dump directly onto the target server.
mysqldump -u aws_username -p"aws_password" aws_dbname | ssh \ a009b438_1@8e47bb3054.nxcli.net "cat - > aws_dbname.sql"
Finally, we can copy the site folder to the new server with rsync:
rsync -avHP /opt/bitnami/apps/magento/htdocs/ \ a009b438_1@8e47bb3054.nxcli.net:~/migration/
A full copy of the entire document root will now arrive on the Nexcess server under the migration folder.
5. Organizing Files and Databases
Now that the document root and database copies have been created, we must sort them to their proper locations on the target system. Let’s swap out the files first. Connect your SSH to your target server, again using the one-line command from your dashboard, but this time from your computer. We do not need to use the AWS server anymore. If you are using OSX, Linux, or Windows 10, the SSH command should already be installed from your shell or command prompt.
Once we have connected to the Nexcess Cloud environment, list the contents of the current directory, and you will see your database (aws_dbname.sql) and folder of site files (migration).
The document root for your live site is located under the folder for your temporary Nexcess domain. This domain looks something like “49deab9ef.nxcli.net”. In this case, our document root would be 49deab9ef.nxcli.net/html/. We first move this directory out of the way:
mv ~/49deab9ef.nxcli.net/html ~/49deab9ef.nxcli.net/html.bak
...and then move our real document root into place:
mv ~/migration ~/49deab9ef.nxcli.net/html
Finally, we will adjust the permissions of the folder so the web server can ensure its security:
chmod 750 ~/49deab9ef.nxcli.net/html
Now that the files are in place, we need to discover our Nexcess database credentials. These are stored in the old CMS configuration file, so again, we use “grep” to output this information (Magento 2 shown here):
grep -e username -e password -e dbname \ ~/49deab9ef.nxcli.net/html.bak/app/etc/env.php
Write all of this information in a safe place; we will use it to finish this section of the tutorial. Now, let’s make a backup of this database and replace it with the database dump from our AWS server:
mysqldump -u nx_username -p"nx_password" \ nx_dbname > ~/49deab9ef.nxcli.net/old_database.sql mysql -u nx_username -p"nx_password" nx_dbname < ~/aws_dbname.sql
6. Configuring Database and URLs
There is one more step to connect the files and the database together. We need to alter the configuration file for Magento to ensure it uses the Nexcess account’s credentials. Open up the file with nano, and take all of the instances of the AWS database information, and replace it with the Nexcess database information:
nano ~/49deab9ef.nxcli.net/html/app/etc/env.php
Once you have finished editing the file, press Ctrl+X to quit, and the editor will prompt you to save; press “y” to write the file to disk.
In addition to this, the site needs to be configured to use the proper temporary domain name from Nexcess, which would look something like “49deab9ef.nxcli.net.” For Magento, this is done by editing a few lines in the database from PHPMyAdmin. You can access PHPMyAdmin through the Nexcess Portal.
Once we are in PHPMyAdmin for the migrated site, we should see our copied Magento data. We want to navigate to the core_config_data table, and change the web/unsecure/base_url and web/secure/base_url lines to match our temporary domain, without and with https as appropriate. Save these changes by pressing return, and exit PHPMyAdmin.
7. Testing Your Data
That should conclude the actual migration of data. We now just need to make sure that what we did worked. This is the easiest part of the migration. Just navigate to the temporary Nexcess URL (such as 49deab9ef.nxcli.net) in your browser.
The first thing we will want to do is flush the cache for Magento in the admin panel. Then, browse around your site as normal and make sure that all of your content is present and works as you expect.
8. Going Live
If everything has gone well up to this point, we should be able to take the new server live to direct traffic to Nexcess.
Before that can happen, the DNS for the domain will need to be updated. This is done at the current nameservers for your domain. You can discover the IP address you will need to use for your records in my.nexcess.net located within your list of plans.
Once the DNS is changed, the primary domain name in Nexcess can be altered to your real domain name. Click on the edit button in the domain options tab in the portal. Enter the domain that you want to change to, and then click on the update button. This will search and replace instances of the old domain in the database automatically, so there is no need to go through PHPMyAdmin again.
Now it is important to ensure that Let’s Encrypt is enabled for this domain, so that an SSL certificate will automatically be installed.
Making It Easier
Migrating a site is not a simple or quick task, even if it can be done. Who has the time to do it all plus their everyday job? Take one thing off your plate with the help of Nexcess.
Our skilled technicians will get to work on your migration and be there every step of the way. With easy, free migrations, top notch support, and the best bang for your hosting bucks — it isn’t just a smart choice, it’s the better choice.
Explore our fully managed hosting plans to get started today.