How to Migrate WordPress or Magento to aMi STACX on AWS.
The reasons to migrate or test migrate to aMi STACX are many. Performance, stack control, simplicity, and a possible reduction in hosting costs.
Although there are many ways you can migrate and many different variations, I'll cover a LAMP migration process that has worked well and is proven. Although this article uses WordPress, the same exact process can be used for Magento.
Important! My blog article assumes you have an intermediate skill level with Linux and basic understanding and experience with the AWS console. If this is all new to you, please hire a professional.
Before you even start, you need to make sure you have all the items my list covered; otherwise, you'll run into snags.
We will define Host A as your migration source, and Host B as the destination to aMi STACX on AWS. We will also assume you are using Windows, Putty and WinSCP as your SSH and SFTP clients. If you are using a Mac or other OS, you may have to hack at a solution. As an alternative, uou can also use our Windows Utility Server >> that comes with a bunch of migration tools such as WinSCP and Putty.
Migration Prep List:
* Admin access SSH/SFTP to Host A
* Ability to run Zip on the Host A server
* Ability to dump MySQL on the Host A server
* [Optional] CloudFlare DNS
* Host B SSH/SFTP access as per our aMi STACX connection docs.
Step 1. Make a Full backup of your Host A before you begin, this also means to include the MySQL database.
Step 2. Clean-up - If you have a bunch of inactive plugins, you can delete them from within the WordPress admin console in order to create a smaller footprint. This also means any log files, caching files, duplicate files, dump files, test files, and anything that doesn't belong with an operational WordPress site.
Step 3. From your source hosting server zip your WordPress document root. [location will vary - ask your provider if you can't find it.] It is easier if you set your current directory to one below your target. e.g /var/www/ with your target being /var/www/wordpress
sudo zip -r zipfile.zip directory
e.g. sudo zip -r /var/www/wordpress.zip /var/www/wordpress
Step 4. From within SFTP you can just drap and drop the finished zip file to your local desktop.
Step 5. Dump the MySQL database from Host A.
As there are many ways to accomplish this task, we will present the one that works 9/10 without issue.
From CLI on Host A: mysqldump -u USERNAME -p DATABASE > backup.sql
e.g. mysqldump -u root -p MyHostADatabaseSource > hostAdb.sql
Note: The dump file should go into your connected user's home directory.
From WinSCP just drag and drop the MySQL dump file to your local device. At this point, you should have both a zip file of WordPress and a MySQL dump file on your local.
Host B Import:
Important! Make sure you have enough disk space before you begin!
On the destination server, Host B, we will assume you already prepared your aMi STACX stack as per the stack directions. You can and should have a placeholder running for testing purposes. Meaning, DNS or EIP in place, and a functioning site according to your end goal. Even if you have to use a hostfile to resolve DNS, you should have all of this prepared beforehand.
Step 1. Copy your migration Zipfile from HOST A to HOST B. Use the default destination path /var/www/wordpress
Assuming you kept your original test worpress directory [you should] rename it to wordpress1.
Step 2. Unzip you zip Wordpress file using:
sudo unzip /var/www/zipfile.zip -d /var/www/wordpress
Step 3. Reset default user/group permissions to the aMi STACX default.
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R u+rwX,go+rX,go-w /var/www/wordpress
Importing the database:
Assuming your skill-set is on par with this article, then you can easily change your MySQL credentials if you want for the new host. For simplicity sake we are going to use the same exact settings from HOST A MySQL for Host B MySQL. Luckly for us WordPress keeps this data in the wp-config.php file.
All this means is after you import the MySQL database from Host A to Host B you need to have the user defined in wp-config.php access to the database defined in the same file.
Important! Make sure the database that you are importing is unique; otherwise, you will get an error. For example, the default database on aMi STACX is named wordpress. More than likely HOST A's database will have a different name and there will be no conflict during import.
Step 1. Import MySQL Dump File. First copy the dump file from your local device to HOST B's /home/ubuntu/ directory. Then proceed with the import:
mysql -u USERNAME -p DATABASE < backup.sql
e.g. mysql -u root -p MyHostADatabaseSource < hostAdb.sql
Testing & Troubleshooting:
Assuming all was set up prior, DNS, vhost, and you are using the correct MySQL credentials. All should be working now!
Check our video for an overview of the entire process.