Question

How to migrate a WordPress website from an apache server of different host to digital ocean's nginx server?

Posted March 12, 2019 2.2k views
NginxApacheWordPressUbuntu 16.04

I need complete step-by-step documentation to do what i asked.
I’ll be very thankful to the person who will give me the right information.

2 comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
3 answers

Greetings!

Thanks for answering my first question there. This isn’t the shortest of processes if you’ve never migrated a website manually before. While I’ll do my best to give step by step, my perspective is of someone who manages servers regularly, and I may overlook something that my mind skips over, something I instinctively assume doesn’t need to be said. I will do my best to provide the steps though.

  • Have HostGator enable SSH (jailshell) for you.

This may require a support ticket. You just need them to run this on their server:

chsh -s /usr/local/cpanel/bin/jailshell cpanelusername
  • Connect to their server using SSH.

Your cPanel username and password are the correct credentials for this.

  • Get the database information. This should work: grep "DB_" ~/public_html/wp-config.php (That may vary if your Wordpress installation is in another folder)

Here’s an example of the details you’re looking for from that output:

define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
  • Dump the Wordpress database to a file. Using the details from step 3, change the appropriate values in this:

    mysqldump -u username_here -p'password_here' database_name_here > ~/database_name_here.sql
    
  • SSH into your new LEMP (Linux, Nginx, MySQL, PHP) droplet.

  • Create database and user. Using same values from step 3 to change the necessary values:

    mysql
    create database database_name_here;
    grant all on database_name_here to username_here identified by 'password_here';
    quit;
    
  • Sync the files over from HostGator’s server to your droplet with us:

    cd /var/www/html
    rm index.html -f
    rsync -avz cpanelusername@gator####.hostgator.com:~/public_html/ .
    cd /root
    rsync -avz cpanelusername@gator####.hostgator.com:~/database_name_here.sql .
    

    (Change “cpanelusername” and “gator####.hostgator.com” to their appropriate values, as well as the databasenamehere value)

  • Import the database:

    mysql database_name_here < /root/database_name_here.sql
    
  • Set file ownership:

    chown -R www-data. /var/www
    

At this point you should be “done.” Every website is unique, especially with the wealth of plugins and configurations out there, so there may be other steps that you have to go through after this. You’ll have to take each problem as it comes and look for it’s solution individually, as one guide cannot reasonably account for all possible variables.

Jarland

Okay! Thanks Jarland for this helpul information. :)

Hello there,

We have a series of tutorials that cover the process of migrating from one Linux server to another which you can check here:

https://www.digitalocean.com/community/tutorial_series/how-to-migrate-to-a-new-linux-server

In general, depending on your site/application you will need to spin up a droplet that matches your current hosting provider environment or at least is suitable for your app/site needs (e.g running the same PHP version). Then you need to migrate your data (files, users, database etc).

Another option is to use the All-in-One WP Migration plugin. The plugin can handle the migration process on your behalf.

https://wordpress.org/plugins/all-in-one-wp-migration/

This article also covers the process, although it is outdated:

https://www.digitalocean.com/community/tutorials/how-to-migrate-wordpress-from-shared-hosting-to-a-cloud-server-with-zero-downtime

The final step will be to test everything and make sure it is working fine and then switch the DNS settings and push your site live from DigitalOcean.

Hope that this helps!
Regards,
Alex

by Ramesh Jha
If you read through this article you'll have the knowledge to migrate your WordPress site from Shared Hosting to a Cloud Server with zero downtime.