I have another website (www.tunerli.com) hosted on one server which is going to expire soon and I’d like to migrate everything (WordPress configuration, database, etc.)from that server to the one that is hosting this www.tunerli.cn.
I did some search online, including WordPress websites, stackoverflow and some other technology related forums and got a general idea on how I should do the work, that is:
- Back up website files
- Export database
- Create database on the new host server and import the data into this new database
- Upload the website files to the new host
- Edit the configuration file to connect to the database on the new server
- Create SSL certificate for the website
- Test and confirm things are good
After backing up things on the old server, I tried to export database with phpMyAdmin, but the old server is too old and I can not get cPanel installed there as it does not support any more, so I decide to go with manual exporting with mysqldump -u username -p db_name > db_backup.sql
and then upload the db_backup.sql
file to the new host with scp
command.
On the new host, as it’s already hosting another website, MySQL is already installed and running, so I just need to create a new database to import the data from the old server. Here are the commands CREATE DATABASES new_db;
mysql -u username -p new_db < db_backup.sql
.
Then I compress all the websites files and upload them to the new host and also make some configuration changes so that it will point to the correct location when this website is visited. Again, I don’t use the WordPress plug-ins to do the upload but choose to do it manually.
After the files are set up, I change the wp-config.php
file so that it will point to the correct database and get the correct data as it does on the old server;
The DNS configuration has already been changed for this domain (www.tunerli.com) so when I test the connection, it points to this new host server and can display the homepage correctly. But then I get another problem which takes me some time to figure out the root cause and get it fixed. I can access the homepage but whenever I click on any other parts or sub-pages, I will be redirected to the other website (www.tunerli.cn) hosted on this same server and will pop up a Nothing Found
error of course as I don’t have this same page and content on the other website. From the apache access log, I don’t find much useful information as it just displays some resolving and accessing information related to the access attempts from external ips and actually it puzzles me more.
Then it comes to me that I have enabled SSL certification for the other website (www.tunerli.cn) with letsencrypt. Hmm, it might be the reason but when I check the certification status with apachectl -S
, it returns SSLCertificateFile: file '/etc/letsencrypt/live/***/fullchain.pem' not exist or is empty
, though the file is there and I can see two chains inside, meaning it’s not empty. Interesting!
So I decide to move on to certify these two domains again with letsencrypt. I get the reminding that the domain www.tunerli.cn is already certified and it asks me whether I want to extend and replace the existing certificate. Why not! And after the certification is done for both of these two domains, things are back to normal! I can access both of these websites as expected and they are running like two totally independent websites hosted on two servers. Great!