How I migrated WordPress from Openshift to DigitalOcean

moving wordpress

CodingisLove was hosted on Openshift online 2 platform for almost 18 months. I was using the free tier of their platform which was really good for a new site. As the traffic increased, I wanted to migrate WordPress to a virtual private server and increase the response time of the site. Also, Openshift announced that their online 2 platform will be shut down by September 30th, 2017 So Its time to move my baby!

I already decided to go for Digital Ocean because of their affordable plans and good support. Also, I had 50$ digital ocean credit from a recent Hackathon 😛 So yeah let’s migrate WordPress!

I’m using Serverpilot to manage my digital ocean server. You should use it too! It makes things so simple, especially for PHP apps and WordPress.

Digitalocean has a One-Click WordPress Installation but If I use that method then only one WordPress site can be used on one server. But I want to use multiple WordPress sites and few other sites on a single digital ocean server. This can be achieved using Server pilot’s setup.

So this article can also be called “How to install WordPress on DigitalOcean using ServerPilot” or “How to install multiple WordPress sites on a DigitalOcean server”

Steps involved in migrating WordPress to DigitalOcean

  • Export exisiting WordPress site using All-in-One WP Migration plugin. You’ll download a bundled file
  • Install wordpress on new digital ocean server using serverpilot
  • Install All-in-One WP Migration plugin in new site and import the site using the previously downloaded file

Only 3 steps? Yeah but there were few problems 😀 Let’s check it out!

Exporting Existing site

This is simple. Just install All-in-One WP Migration plugin. Now go to All-in-One WP Migration > Export from side menu.

Click export to file as shown in image below. Download the exported file. It’ll be something like somename.wpress

Creating DigitalOcean droplet

I’m using a 10$ server which comes with 1GB RAM, 30GB SSD and 2TB transfer per month. This server is ideal for a WordPress site with decent traffic. If your site is still new then you can try out 5$ server too.

If your traffic exceeds 500 per day then go for 10$ server.

If you haven’t signed up for Digitalocean yet then do it using the below link. You’ll get 10$ free credit

SIGNUP FOR DIGITALOCEAN

digitalocean droplet setup

Then select the region closest to your target audience, give a name to the server and hit Create. You’ll get an email with your IP address and root password.

Setup serverpilot on DigitalOcean

We can Serverpilot’s free account for this setup!

If you haven’t signedup for Serverpilot then do it using below link. Its free and you’ll get 10$ credit which can be used later if you want to switch to a pro plan.

SIGNUP FOR SERVERPILOT

Setting up serverpilot is pretty simple. Just enter the IP address of your server, root password that you got in your Email or actual password if you changed it later.

Enter a SFTP password. This is important, Don’t forget this password. Serverpilot creates a user named “serverpilot” with this password. You’ll be using this to SFTP to your server.

serverpilot setup

Install WordPress using Serverpilot

Pay Attention from here!

Go to Apps > Create an App

install wordpress serverpilot

Enter your site name, username, password and email (Don’t worry your previous admin users will be back once migration is complete) check WordPress check box and select PHP 7.1

Read about domain below.



Pointing domain to DigitalOcean

Serverpilot links your domain to new WordPress installation once you point it to your server’s IP address. But I don’t want to point my main domain to new installation without even migrating or testing it. So I pointed a sub-domain first. I would suggest you do the same. I used new.codingislove.com sub-domain first.

Add a new “A” record in your DNS pointing to your server IP address.

I’m using Cloudflare to manage my DNS and also to get free SSL (https) for my site and few other features like caching, DDOS protection etc.

The above “A” record is same for any domain provider though. Use CloudFlare if you want free SSL. Setup is pretty simple and takes less than 5 minutes.

Now hit create > New WordPress will be installed pointing to http://new.yourdomain.com

Import wordpress to DigitalOcean (Migrate wordpress to DigitalOcean)

Now you have a fresh WP installation at http://new.yourdomain.com Go to http://new.yourdomain.com/wp-admin and install All-in-One WP Migration plugin and import your site using the previously downloaded file.

Now you should have your complete old site at http://new.yourdomain.com

But I had an issue, My plugins, themes, and media were not migrated! It might be because Openshift has a slightly different setup for WordPress. Openshift has different folder hierarchy. Follow next step if your plugins and themes were not exported.

I opened a FTP connection using Filezilla to my old site in openshift and copied plugins, uploads folders from wp-content folder and copied locally. Then opened another FTP connection to my digitalocean server and pasted those folders into wp-content folder.

I Did the same with themes but copied only one theme which was the one that I was using.

I could have just installed that theme in the new WP site but I had made changes to the theme files itself so I wanted to retain those changes.

How to FTP to digitalocean using serverpilot user

To connect to your app, complete the following fields at the top of the FileZilla window:

serverpilot ftp

Host: your server’s IP address
Username: serverpilot
Password: SFTP password you gave while connecting the server
Port: 22
Then, click Quickconnect.

Final steps in moving wordpress

So the blog migration was almost complete but one plugin was throwing an error, probably because I copied the entire plugins folder. I just reinstalled that plugin and everything’s normal!

Pointing main domain (naked domain) to new site

As you know, I used my sub-domain new.codingislove.com to make sure that everything is working fine before I use my main domain and also to ensure no downtime for existing users. It’s time to point the main domain now.

migrate wordpress, point domain to digital ocean

Just add “A” record for naked domain pointing to server address. Also, Add “A” record for www if your site is like www.domain.com I’ve set up redirects from www to naked domain in cloudflare so I need not add a record for WWW

WWW is out of trend 😀

One last problem in migrating wordpress

The migration was complete after pointing to root domain! But there was one small problem. Most of my links to https://codingislove.com/* were changed to http://new.codingislove.com/* This might be because I imported old site to new site when new.codingislove.com was the site URL.

Fret not! I just installed a plugin called Better search replace and replaced all occurences of http://new.codingislove.com to https://codingislove.com

Aaaaaand Its done! It seems like a long post but the migration was done in just a few hours.

Using free SSL from CloudFlare with WordPress in DigitalOcean and Serverpilot setup

This step is not required if you don’t need https but it’s better to have SSL

  • Install Cloudflare Plugin
  • Set SSL settings to flexible in your cloudflare dashboard
  • Edit wp-config to use https in home and site URL. If you want to support both http and https then use below settings
  • define('SP_REQUEST_URL', ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']);
    
    define('WP_SITEURL', SP_REQUEST_URL);
    define('WP_HOME', SP_REQUEST_URL);
    
  • Finally If you want to force https always then add these lines to .htaccess file
  • RewriteCond %{HTTP:X-Forwarded-Proto} !=https
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=302,L]
    


Wrapping up

It’s totally worth going for DigitalOcean VPS. Faster the site, lesser the bounce rate and dropouts. Also, I hope google search ranking goes up due to optimized page speed!

The response time of the site is optimized now! It was 3 seconds on average and now It came done to 500ms. The response time for US users should be even better because the server location is US (US traffic is the highest for this blog).

WordPress admin dashboard seems much faster and I’m currently hosting 3 WordPress sites on a single digital ocean server. If you faced any other problems while moving WordPress then let me know in comments below!

Author: Ranjith kumar

A CA student by education, self taught coder by passion, loves to explore new technologies and believes in learn by doing.

Leave a Reply

Your email address will not be published. Required fields are marked *