I was migrating one of my wordpress site to a new server. I followed this digitalocean post to setup the server initially. It was my first time to try to migrate it to a new server. The following is supposed to work
- Setup nginx in new server as in the old server
- Copy /etc/letsencrypt folder to the new server along with permission
cd /etc; tar -cvfp ~/letsencrypt.tar letsencrypt/*
- transfer letsencrypt.tar to new server and move to /etc
tar --same-owner -xvf file.tar
- Setup wordpress
- Copy wordpress directory to new server
- Transfer wordpress database to MySQL in new server
mysqldump -u root -p wordpress > wordpress.sql # export database
- transfer database to new server (say using ftp or dropbox)
- Create wordpress database (step 1 of this guide) and import database with
mysql -u root -p wordpress < wordpress.sql # import database
The complication was letsencrypt. Everything is supposed to work but I kept getting error NET::ERR_CERT_COMMON_NAME_INVALID accessing through both the new ip and the domain name.
It turns out the problem is a redirection problem. I was confused with /etc/nginx/site-available/default and /etc/nginx/site-enabled/default and that also contributes to part of the problem. I was simply editing the wrong configuration file all along. I should have started with /etc/nginx/nginx.conf but I didn’t realize that.
Finally, it is worth mentioning that the following two very useful debugging tools
- Browser error messages from chrome (press f12, go to security and view certificate).
- Using “curl -I sitename” to check how the site is redirected.