How to move wordpress to easyengine based vps


Limited Time Promo, Get Free $20 credit from Vultr, click the banner to get it.

Its almost the end of year. Many offer came and out include hosting. My friend just have her hosting account expire and the reason why she not continue her hosting plan is cost. She got her hosting package last year for $10 (from facebook group). The package cover free domain + 12 month of hosting and when renewal process came she can afford it. Its $104 now. Ten times from previous invoice. She already knew it and try to find other solution to keep her blog alive.

She already red my post about utilize vps. Her blog is using wordpress and she want to try it after she see my other blog that load blazing fast. I told her about Vultr and she could try it for cheapest package.

I promise her to help the migration process in exchange she let me share the process for hostingformula.net reader (I won’t reveal domain name). Hope this useful for others.

Lets get start!

Backup WordPress

In general WordPress is PHP and MySQL application. To backup wordpress the step is quite simple.

1. Backup database

To see all database credentials see wp-config.php content and write it down to notepad or other equal application. I’m lucky the host provide ssh access. So I can use command line for quick access ūüôā

# cat wp-config.php

This command will display the content of wp-config.php . If you just want to extract the database essentials use this command : (my assumptions that you already log in with ssh).

# cat htdocs/wp-config.php | grep DB_NAME

# cat htdocs/wp-config.php | grep DB_USER

# cat htdocs/wp-config.php | grep DB_PASSWORD

Each command will show you database name, database user and database password.

Dump database :

# mysqldump -udb_user -p db_name > backupname.sql

In my case, the dump failed to table crash.

Use mysqlcheck to see the details.

# mysqlcheck -u db_user -p db_name

Enter password:
nita.wp_affp_referrals                             OK
nita.wp_cn_track_post
Error¬†¬†¬† : Table ‘nita.wp_cn_track_post’ doesn’t exist
status   : Operation failed

nita.wp_commentmeta                                OK
nita.wp_comments                                   OK
nita.wp_fgallery_album_images                      OK
nita.wp_fgallery_albums                            OK
nita.wp_fgallery_albums_settings                   OK
nita.wp_fgallery_images                            OK
nita.wp_fgallery_templates                         OK
nita.wp_likes
Error¬†¬†¬† : Table ‘nita.wp_likes’ doesn’t exist
status   : Operation failed
nita.wp_links                                      OK
nita.wp_options                                    OK
nita.wp_postmeta                                   OK
nita.wp_posts                                      OK
nita.wp_stt2_meta                                  OK
nita.wp_subscribe_reloaded                         OK
nita.wp_term_relationships                         OK
nita.wp_term_taxonomy                              OK
nita.wp_terms                                      OK
nita.wp_usermeta                                   OK
nita.wp_users                                      OK
nita.wp_visitor_maps_ge                            OK
nita.wp_visitor_maps_st                            OK
nita.wp_visitor_maps_wo
warning  : Table is marked as crashed and last repair failed
warning¬† : 1 client is using or hasn’t closed the table properly
warning  : Size of indexfile is: 351232      Should be: 157696
warning  : Found 1019968 deleted space in delete link chain. Should be 1020008
error    : Found 7492 deleted rows in delete link chain. Should be 7493
error    : record delete-link-chain corrupted
error    : Corrupt
nita.wp_wp_rp_tags                                 OK
nita.wpsd_trends                                   OK

Wow, since backup not available for certain tables then the only option I have is drop it.

# mysql -udb_user -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 78037
Server version: 5.5.40-0ubuntu0.14.04.1-log (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use nita;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+—————————–+
| Tables_in_nita              |
+—————————–+
| wp_affp_referrals           |
| wp_cn_track_post            |
| wp_commentmeta              |
| wp_comments                 |
| wp_fgallery_album_images    |
| wp_fgallery_albums          |
| wp_fgallery_albums_settings |
| wp_fgallery_images          |
| wp_fgallery_templates       |
| wp_likes                    |
| wp_links                    |
| wp_options                  |
| wp_postmeta                 |
| wp_posts                    |
| wp_stt2_meta                |
| wp_subscribe_reloaded       |
| wp_term_relationships       |
| wp_term_taxonomy            |
| wp_terms                    |
| wp_usermeta                 |
| wp_users                    |
| wp_visitor_maps_ge          |
| wp_visitor_maps_st          |
| wp_visitor_maps_wo          |
| wp_wp_rp_tags               |
| wpsd_trends                 |
+—————————–+
26 rows in set (0.00 sec)

mysql>

mysql> drop table wp_cn_track_post;
Query OK, 0 rows affected (0.01 sec)
mysql> drop table wp_likes;
Query OK, 0 rows affected (0.01 sec)
mysql> drop table wp_visitor_maps_wo;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

Done. All tables are deleted.

Re-run mysqldump

# mysqldump -udb_user -p db_name > nita25nov.sql
Enter password:
# ls -l | grep sql
-rw-r–r–¬† 1 root root 41696899 Nov 25 21:02 nita25nov.sql

Work well this time.

#cd  ..

2. Compress the database + wordpress files

# tar cvzf public_nita25nov.tar.gz public

# mv public_nita25nov.tar.gz public/

#cd public

#nano index.php

Add these lines

<?php
echo ‘Migration to new server in progress, estimation time : 1 day’;
exit();
/**
* Front to the WordPress application. This file doesn’t do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress

In general the lines told to blog audience that the process is in progress.

easyengine2

At this stage backup wordpress is complete.

Backup file accessible from this address.

http://domainname.com/public_nita25nov.tar.gz

Choose cheap vps server for wordpress

I use Vultr for its value. DigitalOcean also nice but since Vultr give more memory (512 MB vs 768 MB) than DigitalOcean so I suggest Vultr.

easy_engine1

For operating system I use Ubuntu 12.04 32 bit. I’ve try it before and consume lower memory that 14.04.

After place order the server will be initialized. This stage is little slower than DigitalOcean but I’ll wait ūüôā

I ever use ServerPilot before but since Serverpilot only support 64 bit architecture then I choose EasyEngine.

Install EasyEngine on Vultr

The installation is straightforward.

Update everything

#apt-get update && apt-get upgrade && apt-get dist-upgrade

Create swap on Vultr

In general swap size is twice as installed memory. Lowest memory Vultr provide is 768MB. Target swap size for 768 MB memory is :

768 x 2 = 1536 MB

I prefer to use fallocate so I check it’s existence :

# which fallocate
/usr/bin/fallocate

You may continue

# fallocate -l 1536M /mnt/swap.img
fallocate: /mnt/swap.img: fallocate failed: Operation not supported

Ups, the command not work.

Old fashion way

# dd if=/dev/zero of=/mnt/swap.img bs=1024 count=1572864
1572864+0 records in
1572864+0 records out
1610612736 bytes (1.6 GB) copied, 3.29304 s, 489 MB/s

How to get 1572864? 1536 x 1024 is the answer.

mkswap

# mkswap /mnt/swap.img
Setting up swapspace version 1, size = 1572860 KiB
no label, UUID=dc4969ce-be42-4748-962b-1432c3ebc5d8

# swapon /mnt/swap.img

# echo  '/mnt/swap.img  none  swap  sw 0  0' >> /etc/fstab

# echo 'vm.swappiness=10' >> /etc/sysctl.conf

Check swap

# swapon -s
Filename                Type        Size    Used    Priority
/mnt/swap.img                           file        1572860    0    -1

or using free

# free -m
total       used       free     shared    buffers     cached
Mem:           748        694         53          0         91        533
-/+ buffers/cache:         69        679
Swap:         1535          0       1535

Back to easy engine :

# wget -qO ee rt.cx/ee && sudo bash ee

Enter your name and your email address when asked.

How to create site on EasyEngine

Easyengine provide many type of sites creation through command line interface. Since my mission is import existing wordpress to easyengine based vps then my choice is create php+mysql site.

# ee site create domainname --mysql

That command will automatically create folder domainname inside /var/www folder . Within the folder you’ll find ee-config.php . This file contain all database credentials.

Import wordpress into easyengine

Download backup file from old host.

# wget http://domainname.com/public_nita25nov.tar.gz

# tar xvzf public_nita25nov.tar.gz

# mv htdocs htdocs-old

# mv public htdocs

# nano htdocs/wp-config.php

Edit the value according to ee-config.php value.

save the file.

Import database

mysql -udb_user -p db_name < nita25nov.sql

At this stage import process is done.

Enable the site on EasyEngine

If you already change A record to vps address then you’ll see nginx page. To see actual wordpress page you need to enable it.

# ee site enable domainname

Finish. At this stage everything should work fine.

A few things that might help you in trace error if needed.

  • logs folder (located inside public folder created by easyengine).
  • wp-config.php (if you have cache solution like wp super cache then you need to inspect related line).
  • email (Vultr block email by default, you need to open ticket. Ask them to enable email for your vps).

Limited Time Promo, Get Free $20 credit from Vultr, click the banner to get it.