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

March 12, 2019 312 views
Apache Nginx WordPress Ubuntu 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
  • Is your other host a VPS/dedicated server or a shared web host? Is it purely a LAMP stack on the other server or does it use a control panel like cPanel or Plesk?

  • It is a Hostgator Cloud Shared Web host, and it uses a Control Panel (cPanel).

2 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. :)

Have another answer? Share your knowledge.