How to move a WordPress site in 10 minutes or less

WordPress Hosting

I’ve had a VPS server at Rimuhosting.com for years to host UseStrict Consulting and other websites. I really enjoyed having root access and all the liberties that come with it. It was going really smoothly until I decided to try out Bitnami instead of the native PHP + Apache installs on my Ubuntu server – “if it ain’t broke…”, right?

But I did touch it and it did break. It turns out Bitnami has some php-fpm memory leaks that I couldn’t get around, and I figured I’d had enough of having to do sysadmin work for the time being. I decided I’d move to a managed hosting company where they’d take care of those issues for me. After some digging, I heard great things about SiteGround (yes, it’s an affiliate link – I like it so much that I endorse it) and decided to try it out.

After moving a few of my sites, I thought I’d share my experience on how to move a wordpress site. Yes, the title says it’s done in 10 minutes or less – I have it down to less than 5, honestly. It depends on how much practice you have, so your mileage may vary. 🙂

The rest of this article will assume that your new host give you access to cPanel and simple one-click WordPress installs. Let me know in the comments if you want the non-cPanel version and I’ll write it up.

Ingredients

Here are the ingredients you’ll need for a quick and easy move:

  1. SSH or SFTP Access to both old and new servers;
  2. cPanel access on the new server;
  3. Access to your domain’s DNS settings;
  4. Remember to replace all occurrences of foobar.com below with the domain you’re moving;

If you’re not familiar with SSH, you’ll be able to do everything using SFTP and other tools like phpMyAdmin, but I find SSH faster. If you’re stuck with a Windows computer, look into getting PuTTY installed. In my days of having to use Windows, I’d also always use Cygwin.

Move a WordPress Site

The first thing you need to do is make sure your new host is ready to receive your domain. Go to your cPanel Home and set up the domain you want to move. If it’s your account’s primary domain, that’s already done. If it’s a secondary domain, create it as an Addon Domain. Let’s assume it’s an addon domain.

Creating an Addon Domain

Click on the Addon Domain icon in the domains section of cPanel. You’ll be taken to a page with a form to set up the new domain.

cPanel Addon Domains Icon

cPanel Addon Domains Icon

Fill in the form with your new domain. The rest (except for the password fields) will automatically be filled in for you. Feel free to change the default values, but for the purpose of this tutorial, we won’t change anything.

Create an AddOn Domain

Create an AddOn Domain

Click ‘Add Domain’ and this part is done. Next, we set up WordPress on the new domain.

Setting up WordPress

Back in your cPanel home, look for and click on the WordPress autoinstaller. Yes, you can choose to install WP yourself, but then you probably wouldn’t need these steps at all. But I digress…

cPanel Autoinstallers

cPanel Autoinstallers

SiteGround uses Softaculous to install applications. Granted, I don’t have much experience with cPanel (I’ve always done stuff manually) so I don’t know if it’s something every host uses or not. When you click on the WordPress autoinstaller, you’re taken to the Overview screen in the installer page. I’ve done this a few times now, and for some reason I’m wired to look for an install button at the bottom of the page. It’s not there. Look for the blue install button right next to the Overview tab.

WordPress Install Button

WordPress Install Button

Once you click on the ‘Install’ button, you’re presented with some basic fields to fill in. As you’re moving your site from your old host here, you really care about the following only:

  • Protocol (whether it’s HTTP or HTTPS)
  • Domain (select the AddOn domain that you just created)
  • Directory (leave empty to install WordPress under /home/youraccount/www/foobar.com)
  • Table Prefix (THIS MUST BE THE SAME AS YOUR EXISTING WP INSTALL)
  • Language (select the language of your existing WP install)

Now, you’ll have to live with the fact that the database name and credentials will be different, so if you have any third-party connections to your existing WordPress install, make sure to change them later.

Click ‘Install’ and wait until the progress bar finishes. You’re now ready to receive your old WordPress.

Export Your Old WordPress

The main thing here is that you want to export a dump of your old WordPress database. I use the terminal via SSH whenever I can. If you don’t like to use a terminal and SSH, export it via phpMyAdmin.

This is what I’d typically do via the terminal (on the old server):

$ mysqldump -u <username> -p  <database> | gzip -c > old-wp-dump.sql.gz

Adding the password to the command line isn’t safe, so we leave it out and get prompted for it after we hit enter. Note that we’re also compressing on-the-fly.

Once you’re done with the database, make sure to create a tarball of your old wp-content directory as well.

$ cd /path/to/wordpress/install
$ tar -czvf old-wp-content.tar.gz wp-content/

Download both files to your computer (or leave them temporarily in a place where you can access them via a browser on your old server).

Import Into the New Server

Now we need to get those two files into the new server. I’m still using SSH, but you can use SFTP if you want to.

First thing to do is to back up your new server’s automatically-created wp-content directory (or rename it using SFTP):

$ mv /path/to/www/foobar.com/wp-content /path/to/www/foobar.com/wp-content.orig

Back up the automatically-created database. You can find the credentials in your new wp-config.php file.

$ mysqldump -u <new-username> -p <new-database> | gzip -c > new-wp-backup.dump.sql.gz

Now move the old server’s files to your new server. If you chose to leave them in a place accessible via a browser, you can use wget (if it’s available in your new host – it is on SiteGround) to download them directly to your server. Otherwise use SCP or SFTP to upload them from your computer.

We’ll need to uncompress the files soon. Unfortunately, SiteGround doesn’t have gunzip, but you can get around that with gzip -d (and even create an alias for it in your ~/.bashrc file – alias gunzip="gzip -d ")

It’s time to do the actual move. The following commands will read the compressed information and handle them accordingly. To import the database, use mysql:

$ gunzip -c old-wp-dump.sql.gz | mysql -u <new-username> -p <new-database>

Again you’ll be prompted for the password after hitting enter. All of the old tables will be created, replacing the new ones as long as you used the correct table prefix when you ran the autoinstaller.

Now uncompress your old wp-content:

$ mv old-wp-content.tar.gz /path/to/www/foobar.com/
$ gunzip -c old-wp-content.tar.gz | tar -xf -

Replace the Auth Keys and Salts

WordPress uses several Authentication Keys and Salts. In order to avoid issues logging into your new server’s install, you’ll have to replace the salts in the new wp-config.php with the ones from your old one.

The entry in wp-config.php typically looks like this:

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         ';LM|C1Op{p`aE>6 FTO64{n#J2c,5KDK6:UxO.OGjHp[`<d%Wj<Fxid-Y_3}#rIn');
define('SECURE_AUTH_KEY',  '6b*K_`ie.A7b2):A-0&|arFv]+b04hT2g93TTRUJHBfp>DL=vJ-a}A9Rh:[email protected]');
define('LOGGED_IN_KEY',    'Q8853bl6ZP-F>r(>wpJhbQu>M|Jt{b6zCcUwR3oyA/6+y<~l#-~,JA-WE.L{[email protected]');
define('NONCE_KEY',        'GzVYsIDpbKi%4,xVODWZRE3w?}[email protected]>I=cM VF[u6AuQF20Cta)Hr9s<hh');
define('AUTH_SALT',        'FmSUv`pq2|%K}yb~r*e)+(,G1}:7I7;/TBxg>h_Ejm0HDD:Y^G&x,yf9t9IRD$3p');
define('SECURE_AUTH_SALT', 'C,QO;+Iu0xw&U}x7}+O_2PS#wn:&z?zh5:75Ys}b[[email protected]|;dgR+R<u8%[B');
define('LOGGED_IN_SALT',   'T_[R}qRiDS2Ye2z|V:A8?ogn,nU[}[+!wcD#W!X.2)ZC8n5*)sC*Y%Ks*&vo++eT');
define('NONCE_SALT',       '[lP_CFP70&i6l- )z(6Cw <o<0ZDG?sxJ&o&.t|m!xkX!z3$QLB.[dG9XRHE^ yd');

Test It

Your migration is now ready for testing. Pull up your new server’s IP address from your cPanel home and add it to your /etc/hosts file (C:\Windows\System32\Drivers\etc\hosts in Windows)

123.123.123.123 foobar.com

Save the file and test your website. You should not see any difference at all when viewing it or logging in.

Once you’re satisfied, change the DNS A entry to point from the old IP to the new IP and that’s it! You’ve moved your website successfully. Allow for a couple of days of DNS propagation before taking your old one down.

As an added bonus, if you’re dealing with a high-traffic site that gets lots of database changes, you can set up Remote MySQL connections in cPanel, whitelisting your old server’s IP for incomming connections, and then change your old server’s wp-config.php to connect to your new server’s MySQL database. That way changes coming from people who still have a cached DNS entry pointing to the old server will be made on the new database automatically.

Important Changes to USC Plugin Sales and Support

When I started selling WordPress plugins at UseStrict Consulting, I planned to provide life-time updates and free support for all. As it turns out, there are a few fundamental flaws with this business model:

  1. There’s no control over unauthorized copies;
  2. Providing free support takes time away from coding new and exciting things;
  3. There is no business growth;

Over the following weeks, I will be implementing a plugin licensing system, and support will be provided to subscribers only. I believe this will be a win-win situation, as I will be able to provide (even) faster support and better plugins.

I’m still studying how to handle old clients, and will post updates as soon as I have more information.

Cheers,
Vinny

eShop Fixed Discounts – Free plugin

So here it is, what many have asked for. You can now offer fixed-rate site-wide discounts for eShop instead of just percentage. You can download it for free at WordPress.org.

eShop Fixed Discounts Admin

Modified Discounts Admin form

eShop Cart with fixed-rate discounts

Cart calculating/showing fixed-rate discounts

If you’d like to also offer fixed-rated discount codes/coupons, please consider purchasing eShop Coupons Plus, which is a substitution for eShop Fixed Discounts.

Cronblocks for WordPress

A couple of years ago I had an idea of a project targeting people who want to offer dynamic content on their sites but do not have the programming knowledge to do so. I called it Cronblocks (http://cronblocks.com) – a system where the user can create snippets of content and choose when to display them. Not satisfied, I decided to add Geo-Location as a possible condition for displaying the snippets. It worked (and still works) fine for sites built in plain html or any programming language as the code is sourced via Javascript.

I recently decided to write a port of Cronblocks as a WordPress plugin as a proof of concept, with the following features:

  1. Snippets are a WordPress Custom Post Type
  2. They can (and should) be grouped into category-like taxonomies called Snippet Groups
  3. Set the snippet controls to use either Geo-Location (visitor’s country) or a Scheduled display time range and date (choose days of the week or days of months)
  4. Assign the Snippets to a Snippet Group (just like categories)
  5. Control overlapping Snippets in a Group with Priorities

To use it, place the Snippet Group shortcode to control where on your page/post you want the appropriate Snippet to be displayed, and that’s it!

The plugin will check for all snippets associated with the shortcode’s Snippet Group and will decide which one should be displayed according to the control settings for each Snippet. If more than one Snippet match the display conditions, a random one of the matching set will be selected.

As mentioned above, this is a proof of concept. I plan on writing a fully featured companion plugin that will offer the following:

  • Enable multiple control conditions of each type, and mix/match
  • Keep and show statistics of snippets being displayed
  • Optionally display snippets based on the visitor’s local time
  • Optionally reload the snippet group after a given amount of time (say a visitor is watching a video, reload the snippet group after 3 minutes)
  • Enable Region and City scope
  • Use Maxmind GeoIP2 database, which is more accurate than the GeoIP databased used in the Cronblocks plugin
  • Allow overriding of snippet options via the shortcode attributes
  • Set up roles that can access the snippet administration
  • Add an icon to the TinyMCE interface as a shortcut to inserting the shortcode
  • Add a Snippet Group Widget

While the fully featured one doesn’t come out, feel free to download the proof of concept from WordPress.org’s plugin repository: Download

 

Didn’t find what you came for?

The cool thing about blogging software is that it shows the blogger all sorts of interesting information, such as the number of visitors, or the search string that led them to the blog.

I see lots of interesting search strings, but I keep wondering if the users actually found what they were looking for. That said, please be kind and leave a message telling me if you found what you wanted, and if you didn’t, please say what it was and I’ll try to cover that in my posts.

You can leave your message either as a comment here, or send me an email through the contact form.

Thanks!!

New looks for usestrict

Folks,

I decided to change the looks of my blog. I’m using Atahualpa theme which is simply amazing. There are over 200 customization options which allow you to do practically anything you want.

If you are wondering about the logo, it is one of Pablo Picasso’s drawings. I chose it because of its simplicity, which is in my opinion one of Perl’s faces (I try not to get on its bad side – K.I.S.S.).

I hope you enjoy it.

Vinny.

DBD::Oracle + Cygwin: Undefined reference error during make

Yesterday I found myself in a position of having to re-master my computer – hence having to reinstall most of the applications including my trusty Cygwin – which always becomes somewhat of a headache when I reach the point of installing DBD::Oracle in it.

This time I got a undefined symbol error. A quick look in Google showed me that Erik Squires had the same exact problem. Lots of searching later, I find that Google can’t find a handy solution anywhere… So I send Erik an email asking about the solution and to my surprise, he answers only 1 (!!) minute after I click send. Talk about a fast reply!!

Hats off to Erik! You will find the solution here: http://cpae.typepad.com/capacity_planning_and_eng/

Hint: the oci.def that he mentions in his post is inside your DBD::Oracle build directory. Don’t get it confused with ocidef.h file in your $ORACLE_HOME/oci/include directory (that’s where I looked first).

I’m adding the error message below with a big SOLUTION header for any Googler out there having the same problem. No need to keep reading if the text above was enough to solve your problem.

Continue Reading…

Future postings on MySQL

On my previous post, I talked about MySQL functionality “insert into … on duplicate key update” which I found really cool. It has since been the most popular of my messages (although nobody leaves any comments), so I guess I’ll start talking more about MySQL… Don’t forget to keep an eye out for fresh Perl updates as well though – the Perl Crash Course is slowly coming out of the oven.

Cheers to all.
Vinny

print “Hello world!n”;

Welcome to Vinny’s Technical Corner. Here you’ll find some (hopefully) interesting posts regarding the *nix world, general programming techniques, Perl, and other languages – web oriented and not.

I’ll try to keep the posts neatly organized in categories, for programming newbies to rocket scientists – in case there’s one out there who would like to share a piece of his/her mind with us…

So, welcome to my blog!