How to Migrate WordPress Site to Digital Ocean Cloud Server
Devopscube was initially hosted on Bluehost. Due to increased traffic, the website performance in terms of load time from Bluehost was not up to the mark. So we moved our website to Digital Ocean cloud hosting which has a drastic difference in site performance and site load time.
If you cannot manage your server, Bluehost or Hostgator would be a better option for hosting your blog in a cost effective manner. In Digital ocean, you need to take care of WordPress setup, security, server patch updates and more. If you a are looking for a good VPS solution, Digital Ocean will be a better option.
Note: If you sign up for Digital Ocean Using this link, you will get a free $10 credit.
Migrate WordPress Site to Digital Ocean
In this article, we have shared a small guide for to migrate WordPress site to Digital Ocen droplet.
Backing Up WordPress files From Current Hosting Provider
You need to backup and get the following data .
1. MySQL file. This 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.
Setting Up Digital Ocean Server
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. In 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.
Chane the default MySQL root password using the following command.
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 apache server.
sudo service apache2 restart
Create database, 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 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 [email protected] IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON devopscube_db.* TO [email protected] IDENTIFIED BY 'password'; FLUSH PRIVILEGES; exit
After this, head over to 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 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.
It will take few minutes to hours for the DNS update. Once the DNS update happens, Digital Ocean droplet will start serving your website.