You can setup Shared hosting with just a few clicks and with many built-in features like Emails, Domain parking, File Managers and so on. Shared hosting can have limitations like MAX_UPLOAD_SIZE(or any PHP.ini settings) as many hosting providers don't allow you to change these settings. Also on shared hosting, you'll have to use only PHP framework, and the limitation lists go on. So today on my blog, I'll show you how to move your website(or WordPress blog) from shared hosting to DigitalOcean or any other provider having your own VPS(Virtual Private Server).

Setup

Courtesy: unsplash.com
  1. Back up your complete website on shared hosting. Every shared hosting service will give you a backup feature of your site. Check your CPanel or contact your hosting service to get your backup. Also, If you use a Wordpress blog download the backup of SQL file associated with your blog.
  2. Sign up at DigitalOcean(Use my ref code to get $10 Credit) and create your first droplet. Choose Ubuntu 16.04 LTS 32 bit image and $5 per month droplet will be good for most of your needs. Make sure to check Monitoring - it's free with a droplet. Click here to see docs on how to create your first Droplet and ways to connect to your droplet
  3. Initial server setup:Initially your droplet has only one user - "root." And this can be dangerous because root has all the privileges and if something goes wrong, it can make adverse changes, even by accident. So you'll need to set up other user and configure the cloud firewall for incoming requests. Click here to see docs on Initial server setup
  4. Update your system:Now on always log in using your new user. After ssh to your droplet run these commands:"sudo apt-get update" "sudo apt-get upgrade" "sudo apt-get dist-upgrade" "sudo reboot"After reboot command, your connection will close and then again ssh to your droplet after 10 seconds.
  5. Buy or point your new domain to DigitalOcean Nameservers:This step is necessary, or else your site will always use IP assigned to droplet - which is very hard to remember for users. Click here to see how you can do this

Installing your preferred server

Servers
  1. The LAMP(Linux, Apache, MySQL, and PHP) Stack:If you want to run PHP apps like WordPress or other CMS or have simple sites, then I recommend installing LAMP Stack. You can also use LEMP(Linux, Nginx, MySQL, PHP) Stack but is a little complex for WordPress - see point 2. Click here to see docs for installing LAMP stack
  2. The LEMP Stack:Click here to see docs for installing LEMP Stack
  3. Additional Tip - Getting free SSL certificate:Nowadays no-one uses paid SSL as Let's Encrypt provides free SSL certificates.If you're using LAMP Stack or Apache server - Click here to see docs getting free SSL - ApacheIf you're using LEMP Stack or Nginx server - Click here to see docs getting free SSL - Nginx
  4. Ruby on Rails:You may want to use Rails app for production. To run Rails, we'll use Apache Server - you can also use Nginx server. These are step by step on how you can install rails:GoRails Guide to setup Ruby and Rails - Use the rbenv method for rails.If you choose Apache Server - Click here to see docs on How To Deploy a Rails App with Passenger and Apache on Ubuntu - Since you already installed Ruby from step 1 - skip till Step 3.If you choose Nginx Server - Click here to see docs on How To Deploy a Rails App with Passenger and Nginx on Ubuntu - Since you already installed Ruby from step 1 - skip till Step 3.When you visit the app, you'll see the error like "bundle not found" or something like this. This error is because Passenger's Ruby directory is not correct. Go to the Configuration section of this Website and edit the file "/etc/apache2/mods-available/passenger.conf" like on the website. Then restart Apache using "sudo service apache2 restart," and you are good to go.
  5. Node.js:First, install the Apache server or LAMP stack using point number 1.Follow this link for node.js - Choose Ubuntu 16.04 as your image.

Installing Wordpress

The WordPress
  1. If you're using LAMP Stack then Click here to see docs on How To Install WordPress LAMP on Ubuntu 16.04
  2. If you're using LEMP Stack then Click here to see docs on How To Install WordPress with Nginx on Ubuntu

Migrating WordPress from shared hosting

  1. Click here to see docs on How To Migrate WordPress from Shared Hosting to a Cloud Server - This is the best and simple guide to migrating. It's old but still works on Ubuntu 16.04.

Setting up mail

  1. Zoho Mail is an email client and is free for up to 25 users. It's easy to set up, just sign up and follow the instructions. You'll need to update your domain settings like MX Records, TXT Records, etc. You can do that using Networking Tab in DigitalOcean.
  2. Zoho has many free apps which may help you like Workplace, Vault, etc.

The End

That's it. These are simple guides but takes a lot more time so be sure to have patience while working on them. I moved to DigitalOcean from a shared hosting service because I now also work with Rails and Node.js apps and PHP has become an older framework for future use. Targetting only to PHP is not beneficial to me. By the way, What's your story for moving from shared hosting to any other cloud providers? Write up below in comments.