Website server migration
2020-07-28
Recently I wanted to migrate my website to a more secure server. My old server's provider was not well known, thus making their servers a bit too shady.
After extensive research, I found a reliable, and most importantly, free solution. AWS EC2 VPS servers.
They offer free 12 month trail, with 750 hours(31.25 days) of rental time each month. This basically means that I can rent a VPS for free for a year.
Resources
小白如何利用wordpress和aws从零搭建自己的个人网站https://www.jianshu.com/p/82db25396e3c
在aws ec2上使用root用户登录https://www.cnblogs.com/520wife/p/7744015.html
AWS server rental process
To start a rental period, you first have to log in to the “root account” (you will be asked to set up when you first sign up for an AWS account) management panel in AWS, which looked a little bit like this
then, click
Service -> EC2 - launch instance
an instance is a VPS, by clicking launch instance, you’ve started the initialization process of a VPS set-up.
There a minimum of three steps in this initialization process. The first one is choosing an AMI, or Amazon machine image. AMI is basically the operating system of your server.
There are plenty of options, such as Ubuntu, Amazon Linux, and red hat enterprise Linux, etc. I have chosen cent-OS 7 since that’s my most familiar OS.
Noted here, for Cent-OS in particular, the option cannot be found in the default recommendation tab. It can only be found under AWS marketplace.
It is also important to look for the “Free tier eligible” sign, because that's the only free option.
You then need to choose the hardware for the server. Unfortunatly, there’s only one option that is free, which is shown below:
However, there’s many advanced options to choose from if your’re willing to pay.
After that, you are basically done. If you want to do further detailed configuration, you have four more steps to go.
Out of the four “sub-steps”, the most important one is step 6, which allows you to open up different protocols and ports. If you want to customize your ssh ports, for example, you can add a new inbond rules on port xxxx.
Connecting to AWS server
I used Putty for this connection process. Prior to this rental, the server provider always provide a random password for the root user. This time however, I need to use a key generated by AWS.
This key is downloaded as a .pem file, with a name your come up with. Then, I have to open puttyGen, and load that .pem file in:
It will show up the content of the .pem file. You then need to press save private key to save a .ppk file.
This new file is the key that will log you in to your server. So next you will open Putty, and find the Auth option under the SSH option.
in the “private key file for authentication” space, click browse and find the .ppk file that you just save, then click open to log in.
Enable password authentication
Password authentication is turned off by default. This creates a lot of limitations if I want to ssh into the server directly/immediately. Hence it is necessary to turn the password authentication back on.
To do that, we first need to login as the root user. We can do this by creating a password for the root user
passwd root
then login as root using the password
su root
we then need to turn on password authentication. That is located in the file sshd_config, hence
vi /etc/ssh/sshd_config
find the line
PasswordAuthentication no
and turn the “no” to “yes”. After that, reload sshd
sudo /sbin/service sshd restart
Next time when you log back in, test using root and an inquiry for user password should be seen.
Web content migration
Now it’s for the part of content migration. I was able to achieve the migration through a WordPress plugin called “All in one wp migration”(ai1wm for short)
This plugins allow the user to export, import and backup thier website.
However, after the version 6.8 update, the plugin started a limit on the maximum size of the website upload, which creates problems if you have a big website.
On top of that, WordPress itself also has an uploading size restriction. So to mitigate all these problems, we have to download:
- the v6.7 of ai1w
- and a plugin called “tuxedo big file upload”
which unlocks both upload restrictions.
To start migration, you would need ai1wm on both servers(old and new).
You first export your website into a .wpress file via export in ai1wm:
Then, you will install the ai1wm v6.7 on your new server. Through either server panel or ssh, you will need to upload the .wpress file you’ve just created into the ai1wm backup folder:
Default path: /www/wwwroot/your_website_url/wp-content/ai1wm-backups
After that, go to the backup tab in ai1wm and restore the backup that just showed up.
You’ll need reload your website again, and enter the username and password of the old website, and your’re good to go.