Bivori - The truth as I saw it!

  • Home
  • Privacy Policy
  • Sitemap
    • Posts
    • Pages
    • Categories
    • Tags
  • RSS Feed
  • Subscribe
  • About
  • Contact
  • Resources
You are here: Home / Hosting / How to move from BlueHost to DigitalOcean Cloud VPS Hosting

How to move from BlueHost to DigitalOcean Cloud VPS Hosting

By: Suresh Khanal | Filed Under: Hosting, Virtual Servers | Last Update: April 19, 2016

BlueHost to DigitalOcean – Step-by-Step explanation of my process!

The migration process is over successfully! I moved one of my site from BlueHost shared hosting to DigitalOcean VPS server. It was a quick and enjoyable process.

With a hope that it’ll be useful to you too when you decide to move away from BlueHost and land on DigitalOcean unmanaged cloud VPS, I’m explaining the process here.

Suresh Khanal, Fly to Everest, Shooting of Big Foot Documentary on 13 Oct 204

Ready to fly to Everest on 13 Oct 2014

BlueHost to DigitalOcean migration process – Here I relate exactly what I did to move my mcqsets.com site that was hosted in BlueHost shared plan. Now it is served from a separate droplet in DigitalOcean cloud VPS. Before we dive into the procedure, let me put some basics first.

What is cloud VPS?

You probably know it already that there are two forms of hosting – shared and dedicated. Shared hosting will share the same physical server among many clients while in the case of a dedicated server, a physical computer is dedicated only to you – You won't share computing resources to anybody else!

That sounds dedicated server is the best choice, isn’t it? But, wait! It may be much expensive than you really need :D

Dedicated hosting can further be divided into two categories – physical and virtual. In the case of a physically dedicated server system,  you purchase or rent one computer to host your site and servers. Whereas in virtual servers, it’s not a physical server but you get the equivalent services – independent from any particular machine. The former method suffers the single point failure.

Now these virtual servers, if they are created in cloud computing environment they make up your VPS by combining services running on different computers in the cloud. Due to its redundancy feature cloud VPS are free from any single-point failure. Thus, they can offer a much stable hosting without any downtime at all.

Cloud servers work in the same way as physical servers but the functions they provide can be very different. It allows you to choose a different configuration, operating system and software facilities that would never be possible with physical servers.

When opting for cloud hosting, you are renting virtual server space rather than renting or purchasing any physical server. They are often paid for by the hour depending on the capacity required at any particular time. Thus, it is possible to upgrade or downgrade VPS on the fly!

Why DigitalOcean Cloud VPS?

Well, I’ve already discussed this topic in details. Instead of replicating, let me point you to that post:

http://bivori.com/hostgator-to-digitalocean/

To summarize, the main points were:

  • Economical – $5/month is really cheaper than most shared hosting
  • Total Control – Nobody else holds the control of your system. Do it whatever you wish.
  • Flexible – choose what suits you, the operating system, web server, database management system for each VPS
  • Free from bad neighborhood – You are not sharing your public IP with any other sites.
  • and much more! Read the post to explore them yourself!

How I moved my site from BlueHost to DigitalOcean hosting?

Okay, it’s now time to do some real work. Sleeves up!

Step 1: Create new droplet

To move from BlueHost to DigitalOcean, the first step obviously, is to create a new droplet, i.e. your VPS. It is ridiculously easy to create a new droplet in DigitalOcean. All you have to do is to click on ‘Create’ button after you log in to DigitalOcean.

 

BlueHost to DigitalOcean - Create New Droplet in DigitalOcean

Don’t have an account in DigitalOcean yet?

Simply visit DigitalOcean then supply your email address and preferred password and click on Create Account button!

Simple, isn’t it?

Once you click the Create button, it will open up a form where you can enter your domain name, select the droplet size, choose a region from where to host your site; and the image (operating system) to deploy on your droplet. Finally, click Create Droplet button at the bottom! It’s done! You’ll get an email instantly with the login credentials.

Confused about the required droplet size for your blog?

Read: What is the best droplet size for your WordPress blog?

Which Image to deploy on your droplet?

This can be pretty confusing at first. You can get one click installers to install LAMP, LEMP or even WordPress. The choice of operating system is just the matter of your taste. However, I suggest you to go with Ubuntu 14.04 for two reasons:

(1) One click installers will install and configure for most general uses. It may not be optimized for your specific requirement. Moreover, because we are leaning on low powered VPS ($5/month), it is wiser to install only that truly requires for the functioning of your blog.

(2) Ubuntu 14.04 is the latest operating system and there are sufficient tutorials and support documentation for this. Thus, you’ll find it relatively comfortable to configure your VPS.

Step 2: Add your domain name to the droplet

Okay, you have your first droplet in DigitalOcean (Please, don’t confuse with the term ‘droplet’. It simply means a VPS instance in DigitalOcean). Now it’s time for your domain name to point to this droplet so that the visitors get your site when they browse for it.

Don’t have a domain name yet?

Simply visit GoDaddy and search for your preferred domain name. You can find some coupon codes to offer heavy discounts for GoDaddy domain names.

There are two tasks to accomplish to add a domain name to your VPS – (1) Point your domain name to DigitalOcean name servers and (2) Create DNS record for your domain in DigitalOcean.

I’ve explained the process in detail in my previous post.

Read: Add GoDaddy Domain name to DigitalOcean VPS ?

In the post above, I used GoDaddy as domain registrar because I’ve my domain names registered there. If you have a domain name from any other provider, the process will still remain the same.

All you’ll have to do is to change the name server of your domain name!

After you complete this step, it will take a few hours for your domain name to propagate all the routers. Stay calm!

Step 3: Install some tools in your PC

For those who are using Linux, it is fine! There’s Linux terminal to log in and manage your VPS. But, for someone still using Windows like me, you’ll find a couple of software very handy.

I’ve discussed these different applications and offered download links in my previous post. Please visit the following link:

Read: VPS and the Tools on my PC to access & manage

Among the different tools, I use PuTTY and WinSCP more frequently. You’ll love them to have installed in your PC.

Please visit the link above also to learn how you can log in to your droplet using any of the tools described there.

Step 4: Prepare VPS to import your blog from BlueHost to DigitalOcean

Before you can import the blog files and database, you need to prepare your droplet. There are some recommended configurations and the security settings.

Please visit the link below to learn about how to prepare your droplet before you import your blog.

Read: Prepare your VPS to host WordPress blogs – Essential and Security Configurations

In the post above, I’ve explained about creating a new working linux user, grant sudo privilege to the user, changing default ssh port, restrict root login, allowing only a specific user to log in ssh, install and activate Fail2Ban to block brute force attack.

Now after these server settings, we move forward to install and configure the software required to run a WordPress blog.

Step 5: Install Nginx web server

In order to display web pages to our visitors, we need some kind of web server running on our VPS. Nginx is one such modern, efficient web server. Apache, the popular old web server software, though still holds a good ground  is declining, leaving more space for Nginx. More and newer deployments are based on Nginx servers nowadays.

Should you doubt or interested to compare which one to install for your droplet, I appreciate you checking Nginx Vs Apache on Anturis or Choosing a Linux web server in IT World.

Okay, if you are convinced, let’s proceed to install Nginx server in your VPS.

#1. Let’s update the local package index

#2. Install Nginx

sudo apt-get update
sudo apt-get install nginx

In Ubuntu 14.04 Nginx is already configured, so, it’s ready to run.

Try in your browser entering your IP address or domain name:

Welcome to Nginx
Welcome page to indicate successful installation

Voilà ! It was so easy, wasn’t it?

Step 6: Install MySql Database

MySQL is a popular choice of database for use in web applications and is a central component of the widely used LAMP & LEMP software stack. By LAMP, I meant Linux, Apache, MySQL, Perl/PHP/Python. Similarly, LEMP is the software stack where Apache is replaced by Nginx. Because we did not use Apache, our configuration is LEMP.

Okay, that was just background information – nothing to do with installing MySql. Let’s proceed with our business now.

#1. Install my-SQL server

sudo apt-get install mysql-server

#2. The installer will ask you for database root password. Remember, it’s not the Linux root password but a new password you wish to set for the mySql server.

#3. Once my-SQL is installed, proceed forward to generate directory structure for the database. Issue following command in your console:

sudo mysql_install_db

#4. Finally, secure your my-SQL server by running a wizard. Issue the following command for that:

sudo mysql_secure_installation

#5. The secure installation will ask you for the password and here it’s the my-SQL root password that you’d set in step #2. Once the wizard is complete, MySql is ready to run!

Step 7: Install PHP

Till now, we have a VPS that is efficient and secure, Nginx to server web pages, MySql to store and retrieve data required. And now, it’s turn to install PHP so that our VPS can process to create and deliver dynamic content connecting web server (Nginx) and database (MySql).

The two PHP modules are important for us to install: php5-fpm and php5-mysql. The former will process the PHP codes. Nginx will pass PHP requests to this server for processing. And the later will allow PHP to communicate with our database backend.

Though, this is a long description and sounds super wow! all you have to do is issue one command. Here’s it:

sudo apt-get install php5-fpm php5-mysql

Step 8: Fix Security Setting for PHP Processor

We got our PHP processor, however, there’s a small problem. The default configuration of php5-fpm contains an extremely insecure setting and should be fixed. The php5-fpm configuration file is located at /etc/php5/fpm/php.ini. Follow the procedure below to fix it up!

#1. Open php5-fpm configuration file in your favorite editor (nano till now)

sudo nano /etc/php5/fpm/php.ini

#2. Find the line ;cgi.fix_pathinfo=1. You can use Ctrl+W to search in nano editor.

#3. You should remove the semicolon at the front and change the value to 0. Because cgi.fix_pathinfo tells PHP to attempt to execute the closest file it can find if a PHP file does not match exactly, it is extremely insecure. After you make change, it should look like:

cgi.fix_pathinfo=0

#4. Save and close the file. ( Ctrl+X, Y, Enter)

#5. Apply the change you made by restarting php5-fpm
sudo service php5-fpm restart

Step 9: Create a folder to import your site files

Now, you have everything ready. It’s time to make some room to import your WordPress files and create database to import database.

Nginx by default looks for website files at /usr/share/nginx/html. However, it will be convenient for you if you create a separate folder to host your site from. We’re creating folder at /var/ directory instead of /usr/share/nginx/html.

Issue following commands to create and prepare your directory.

sudo mkdir /var/www/html

In my case I created /var/www/html/mcqset. It will be easier for future if I wish to add more sites in same droplet. I can host another site in another subdirectory inside html directory such as /var/www/html/icttrends.

For this tutorial purpose I’ll use html directory to store site files.

sudo -R chown www-data:www-data /var/www/

The above command will make www-data as the owner of the directory, and -R switch will instruct that the same setting has to be applied for subsequent subdirectories as well.

Step 10: Configure Nginx to serve files from your folder

As we created a separate folder to host our files which is different than the Nginx default /usr/share/nginx/html, we need a little configuration. After than it will look into your folder /var/www/html to serve files from.

#1. Navigate to sites-available folder and create a new file there.

sudo nano /etc/nginx/sites-available/domain

#2. Insert the following text into the file and changes the values colored red to reflect your server. You can select and copy from this page and, to paste it in nano editor, simply right click.

server {
listen 80;
# listen [::]:80 ipv6only=on;

root /var/www/html;
index index.php;

server_name domain.com;

access_log /var/log/nginx/domain-access.log;
error_log /var/log/nginx/domain-error.log;

fastcgi_read_timeout 150;

location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 150;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}
}

#3. Activate this setting by creating a symbolic link of this file into the sites-enabled folder. Use the following command to create the link.

sudo ln -s /etc/nginx/sites-available/domain /etc/nginx/sites-enabled

#4. Remove default from sites-enabled to avoid confusion to Nginx

sudo rm /etc/nginx/sistes-enalbed/default

Step 11: Create Database and User

The required directory is ready. Now let's create a database in MySql so that we can import data from existing database in BlueHost. Because we don’t have PhpMyAdmin or any other management application installed in our droplet, we’ll have to do it using ‘command line'.

To save resources and let your blog run efficiently, it is better to install only the minimal applications. That’s why I did not installed phpMyAdmin or any other.

It’s fairly easy to create a new database, a new database user, and grant required privileges to the user. Follow the procedure below:

#1. Log in to MySql server

mysql -u root -p

#2. Supply the password you set for mySql root user and press Enter.

#3. The command prompt changes into mysql> to let you know that you’re in MySql environment now.

#4. Create a new database (let’s name it dbmcqsets)

mysql>create database dbmcqsets;

#5. Great! You created a database. Now let’s create a user who can access the newly created database.

mysql>create user wp-user identified by password

Change the username wp-user as you prefer and password by some secure one that you can remember. We’ll need this username and password after we import WordPress.

#6. Grant privileges to this user

mysql>grant all privileges on dbmcqsets to wp-user;

Change the dbmcqsets with your database name and wp-user with your username.

#7. Apply the specified privileges:

mysql> flush privileges

#8. Exit from MySql

mysql>exit

Note: Should you confuse or wish to learn more about the mysql database user privileges, please refer to how to create a new user and grant permissions in mysql

Awesome! You have now prepared the VPS to import your WordPress blog into DigitalOcean droplet. Let’s bring in the site files first!

Step 12: Import Site Files

You can access Filemanager from BlueHost cPanel and zip the folder that contains files for your blog. If you download the file and upload to your DigitalOcean droplet, you can unzip and make it usable there. However, it will take much longer time to download to your local PC and upload it again to the DigitalOcean server. Rather, the better method is to transfer the file directly from BlueHost server to DigitalOcean server. Please follow the procedure below to transfer the file directly through ssh.
#1. Enable ssh access in your BlueHost account.
BlueHost by default do not support ssh access. But, you can enable it from through the cPanel. Log into your BlueHost account then click on cPanel link. Scroll down the page to find security group. Open SSH/Shell Access by clicking it.

SSH Shell Access in cPanel
SSH/Shell Access application in cPanel

On the resulting page, check if SSH is enabled or not. If it is not, you’ve got a button ‘Manage SSH Access’. Enable SSH Connection through the resulting page.

Enable SSH BluHost
Enable SSH Access in BlueHost

#2. Create Zip file of your site
As you are already logged into your BlueHost account, it will be easier to open File Manager in cPanel and create the zip file of the folders from where you are hosting the site. By default, it is the public_html folder if you are not hosting multiple blogs from same account.

Note down the location where you stored the zip file. We’ll need it while importing from DigitalOcean.
#3. Import zip file to DigitalOcean
After you enable SSH access to BlueHost and your zip file ready, you can import it in DigitalOcean. Now, switch back to your PuTTY application. Issue the command below to import zip file.

scp [email protected]:/path/to/file /var/www/html

It will ask password for your BlueHost account, do supply it. The file will be copied and stored in the destination path you specified. It may take a few seconds and our PuTTY may appear unresponsive. Stay calm till you see the prompt again to appear on the console.
#4. Unzip the folder
So you have zip file in /var/www/html. You should extract the contents to make them usable. In PuTTY console issue the following command to extract files:

unzip /var/www/html/siteFiles.zip

Replace the filename with the actual filename you imported.
#5. Update wp-cofig.php file
The files will work perfectly but you’ll need to update the wp-config.php file so that it will point to the correct database connection. Open wp-config.php file using following command:

sudo nano /var/www/html/wp-config.php

In this file make changes so that you define database name, username and password. Change following values marked with red color.

define('DB_NAME', 'dbmcqsets');

/** MySQL database username */
define('DB_USER', 'wp-user');

/** MySQL database password */
define('DB_PASSWORD', 'sqlPassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Save the file and close it.

So, your site files are ready now. All that’s left is to import database.
Step 13. Import Database
The process of importing Database is not much different than importing site files. To import your WordPress database, we’ll dump it in a .sql file and transfer that file to DigitalOcean droplet. Once it arrives, we use it to populate the database we’ve created in Step 10.

To create .sql file, you can use PhpMyAdmin application in BluHost cPanel or issue mySql command

mysqldump -u root -p databaseName> databaseName.sql

If you prefer to use PhpMyAdmin in BlueHost cPanel, follow the procedure below to create .sql file

#1. Log in to PhpMyAdmin ( You should provide your BlueHost Password to log in after you click on PhpMyAdmin icon in cPanel)

#2. Click the database name from the left panel to select.

#3. On the resulting page click on Export tab.

Export tab in PhpMyAdmin Screen
Export tab in PhpMyAdmin Screen

#4. Once you are in the Export page make a selection as in the image below and click Go.

Export Page in PhpMyAdmin Screen
Export Page in PhpMyAdmin Screen

This will create a .sql file with the same name as database name and store in /home/yourAccountName/tmp folder. Once you have this file, you can copy it to your DigitalOcean droplet as you copied .zip file in the earlier step.

Issue the command below in your PuTTY console to copy the file in DigitalOcean droplet.

scp [email protected]:/home/yourAccountName/tmp/database.sql /var/www/html

Have patience while copying. Depending on the size of your .sql file, PuTTY console may appear unresponsive for a few seconds.

Once the file is imported to your /var/www/html folder, issue the following command to populate your database with the data from the .sql file.

mysql -u root -p dbmcqsets < database.sql

If everything went well, the above command will create the exact copy of database in DigitalOcean as it was there in BlueHost.

Step 14: Clean Up

By now, you’ve migrated your WordPress blog from BlueHost to DigitalOcean VPS. Congratulations! But we have two backup files that we copied to DigitalOcean. You may wish to keep them safe somewhere out of the /var/www folder or simply delete them.

Well, that’s all! You got your blog moved successfully. Hope it was a quick and enjoying migration process! Happy blogging!

Similar: BlueHost to DigitalOcean Hosting  |  BlueHost Vs. DigitalOcean

Related

Tagged With: BlueHost, bluehost to digitalocean, cloud VPS, DigitalOcean, Hosting, Migration, WordPress

Comments

  1. Raju Rimal says

    January 6, 2016 at 10:56 am

    Sounds, very interesting. Although you have full control, isn’t is difficult to manage the whole system by your own, since you have to deal with security, update and upgrade, troubleshooting etc.

    Reply
    • Suresh Khanal says

      January 6, 2016 at 11:16 am

      That’s very genuine concern, Raju. It took little while for me as well to dare lift the globe, however, DigitalOcean has enough tutorials and to host WordPress blog, there’s very limited configurations to do.

      Anyway, for the first blog to host with your VPS, it will take a bit of your courage to learn it!

      Reply
      • Raju Rimal says

        January 6, 2016 at 2:54 pm

        It has made me interested in digital ocean since you will have your own computer in cloud and you can have your personal server whatever the server be. I still have my hosting with hostgator till 2018, so, I will think about switching after that.

        Reply
        • Suresh Khanal says

          January 6, 2016 at 2:57 pm

          That’s perfectly fine!
          BTW, how’s HostGator doing these days? I was really fed up with the problems and response time their support took those days.

          Reply
  2. Ali says

    April 17, 2016 at 2:58 pm

    This article was very helpful for me because i was facing problems… thanks man you solved them… keep on sharing more with us….

    Reply
    • Suresh Khanal says

      April 20, 2016 at 1:06 pm

      Hi Ali,
      Glad to see it worked for you. Cheers!

      Reply

Leave a Reply Cancel reply

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

Free Subscription

Theme of the month!

StudioPress Theme of the Month

Reviewed Products

  • MyEcoverMaker - The Online 3D Cover Page Generator
    MyEcoverMaker - The Online 3D Cover Page Generator
    8.8
  • WP Auto Affiliate Links
    WP Auto Affiliate Links
    8.1
  • WP Product Review
    WP Product Review
    7.9
  • GetResponse Email Marketing Solution
    GetResponse Email Marketing Solution
    7.7

Latest Reviews

WP Product Review

WP Product Review

79.1

Buy NowRead Review

GetResponse Email Marketing Solution

GetResponse Email Marketing Solution

76.84

Buy NowRead Review

Recommend Products

Commun.it Blog Directory & Business Pages - OnToplist.com

Recent Posts

  • Google Adsense Matched Content FAQ
  • Web Hosting and Types of Web Hosts « How to Blog Series: Post #9
  • How to add featured images in WordPress feeds?
  • Free WordPress themes are not for newbies
  • How to setup RSS-to-Email with GetResponse

Comments

  • Suresh Khanal on HostGator to DigitalOcean – The love/hate story!
  • Suresh Khanal on MyeCoverMaker Review – My Favorite Book Cover Maker
  • Suresh Khanal on Google Adsense Matched Content FAQ
  • Suresh Khanal on Google Adsense Matched Content FAQ

Categories

  • Blogging
  • Domain Names
  • Email Marketing
  • Hosting
  • How to Blog Tutorials
  • Income
  • News
  • Plugins
  • Useful Tools
  • Virtual Servers
  • WordPress Themes

Twitter Timeline

My Tweets

Affiliate Links Disclosure

I review different products and services that receive compensation from the companies whose products I review. I test each product thoroughly and give high marks to only the very best. Bivori is independently owned and the opinions expressed here are my own.

Top Engagers

    No one has commented since the last reset. Leave an approved comment and your site name and latest post will be shown here

Popular Posts

  • MyeCoverMaker Review – My Favorite Book Cover Maker
    MyeCoverMaker Review – My Favorite Book Cover Maker
  • Google Adsense Matched Content FAQ
    Google Adsense Matched Content FAQ
  • VPS and the Tools in my PC to access & manage
    VPS and the Tools in my PC to access & manage
  • Add GoDaddy Domain name to DigitalOcean VPS ?
    Add GoDaddy Domain name to DigitalOcean VPS ?

About Suresh Khanal

A part time blogger and online tutor. I love to share the truth as I saw it.

Connect with me on Facebook, Twitter and Google+.

Apart from blogging in Bivori, I love to help students of Computer Science and the candidates of Computer Jobs exams at MCQ Sets and PS Exam. Read More…

Sitemap | RSS Feed | Subscribe

Copyright © 2018 · This blog uses Eleven40Pro Theme On Genesis Framework ·