How to Migrate WordPress Site to Digital Ocean Cloud Server

migrate wordpress to digital ocean

In this article, I have shared the guide for migrating the WordPress site to the DigitalOcen droplet.

Devopscube was initially hosted on Bluehost. However, the website’s load time from Bluehost was not up to the mark due to increased traffic. So we moved our website to Digital Ocean cloud hosting, which drastically differs in site performance and site load time.

Bluehost or Hostgator would be a better option for cost-effectively hosting your blog if you cannot manage your server. In the Digital ocean, you must take care of WordPress setup, security, server patch updates, and more. If you are looking for a good VPS solution, Digital Ocean will be a better option.

Migrate WordPress Website to Digital Ocean

I have organized the WordPress migrations into multiple categories. Please follow each category and the steps mentioned in it.

Back-Up WordPress files From the Current Hosting Provider

You need to back up and get the following data.

  1. MySQL file. You can get it from the PHPMyAdmin page of your existing hosting.
  2. Complete wp-content content folder from current hosting.
  3. If you added custom rules in the .htaccess file, backup and download the same.

Spin Up a Digital Ocean Droplet

1. Launch the droplet using one click WordPress ubuntu 14.04 image.

2. Log into the server using ssh. Note down the details in the welcome message.

3. Update the server

sudo apt-get update -y

5. On the welcome page, you can see all the default Mysql and PHP details (Default MySQL root password, php.ini location, etc). You can also view it using the following command.

cat /etc/motd.tail

Change the default MySQL root password using the following command.

mysql_secure_installation

Setup PHPMyadmin

PHPMyadmin makes it easy to import the database and manage new users.

1. Install PHPMyadmin

sudo apt-get install phpmyadmin

2. Enable php mcrypt.

sudo php5enmod mcrypt

3. Open /etc/php5/apache2/php.ini file and increase the file_upload_limit and post_max_size parameter to 50MB or more depending on your SQL file size.

3. Restart the apache server.

sudo service apache2 restart

Create a database, and user, and import the database

Create a new database and a database user using PHPMyadmin page. Make user you give all the privileges to the new user to the database you create.

You can also create a database and user using MySQL CLI with the commands given below. Change the database name, user name, and password accordingly.

mysql -u root -p
CREATE DATABASE devopscube_db;
CREATE USER db_admin@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON devopscube_db.* TO db_admin@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

After this, head over to the PHPMyAdmin page and log in with your DB credentials.

1. Now select the created database and click the import option.

2. Upload the SQL backup file you downloaded from your current hosting provider and click import. This will import all your WordPress data.

Upload wp-content folder

1. Upload the wp-content backup folder to Digital ocean droplet using SCP or a tool like FileZilla.

2. Replace the default wp-content droplet folder with your wp-content folder in /var/www/html folder.

3. Change the wp-content folder owner to www-data

sudo chown -R www-data:www-data /var/www/html/wp-content

3. Open wp-config.php file and change the database, database user, and password. Also, check the table prefix parameter. If your existing table prefix it is other than wp_, change it in the wp-config.php file.

Map the IP to Domain Name

  1. Copy the droplet public IP from the Digital ocean panel.
  2. Open the DNS zone editor of your domain name from your domain name provider and update the A record to digital ocean IP.
  3. It will take a few minutes to hours for the DNS update. Once the DNS update happens, the Digital Ocean droplet will start serving your website.

Conclusion

In this guide, I have covered the essential steps in migrating the WordPress website to the digital ocean cloud.

In Digitialocean, you must ensure you patch the server monthly to avoid any server security incidents.

If you are looking for a managed cloud hosting platform with Digital ocean as a backend cloud, you can take a look at Cloudways hosting. It takes away all the administrative overhead on performance and security. Here is the detailed Cloudways review

You can get started with the platform for free using the cloudways promo code.

1 comment
  1. Pingback: Amazon Launches Lightsail, a VPS at Just $5 - DevopsCube
Leave a Reply

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

You May Also Like