28 March, 2020

How to Move Your Wordpress Site From One Server ( or localhost) to Another Server?

Simple steps to deploy existing WordPress site
Hey everyone,
  • Do you want to migrate your WordPress site to a server from localhost?
  • Do you want to move your site from one server to another?
If one of your answers is Yes then you are at the right place. This article will surely help you.

You need to follow some simple steps in the correct order :

<ol>
    <li> Create a backup of your WordPress site </li>
    <li> Move backup to your new server </li>
    <li> Setup site on the server </li>
    <li> Redirect site to your domain </li>
</ol>


1. Create a backup of the site

    <p> First, we need you to backup your site to move this on a new server. For this, we are using a Wordpress plugin, called Duplicator. <br />
    Duplicator has a great rating on WordPress repository and it's free as well. Feel free while using this plugin because it will take the backup of all your database, themes and plugins as well. <br /> </p>
    <p> So for backup, you have to follow the following steps : </p>

    <h5 > 1. Download and install Duplicator plugin on your local site </h5>
    You can download the duplicator plugin from your WordPress site dashboard. <br />
    From dashboard navigate to <b> Plugins  ➡ Add New  ➡ </b> Search <b> Duplicator ➡ </b> click on <b> Install Now ➡ </b> click on <b> Activate. </b>
    <br /><br />
    <figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/513a65d833-1611399527/1-Duplicator_install.jpg"></figure>
    <br />
    <h5> 2. Create a new package </h5>
    Now you can see Duplicator in your dashboard. To create a new package, navigate to <b> Duplicator ➡ Packages ➡ Create New </b>. <br />
    <br /><br />
    <figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/30d15cb603-1611399527/2-Duplicator_create_new.jpg"></figure>

    Here we have three steps :
    <p>
    <b> 1-Setup : </b> Click on the <b> Next </b> button to start the process.
    <br /><br />
    <figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/5898d77d7b-1611399527/3-Duplicato_setup.jpg"></figure>
    <br />
    </p>
    <p>
    <b> 2-Scan  : </b> Click on the <b> Build </b> button.
    <br /><br />
    <figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/cdb9b0c20a-1611399527/4-Duplicator_scan.jpg"></figure>
    <br />
    </p>
    <p>
    <b> 3-Build  : </b> Now download both the <span style="color: #008000"> Installer </span> and <span style="color: #008000"> Archive </span> files.
    <br /><br />
    <figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/d8fcf489a0-1611399527/5-Duplicator_build.jpg"></figure>
    <br />
    </p>

You can follow these steps also to backup your site. Now, we need to move our backup (these two files) to the server.

<h4> 2. Move your backup to the server </h4>
<p> Let’s move your site to the server so that various approaches can be used. You can use your FTP client also, but here we are using an rsync command to send files from local to the server. For error-free installation follow given steps : </p>
<ol>
<li> Move your <span style="color: #008000"> Installer </span> and <span style="color: #008000"> Archive </span> files in a new folder. We have named it <span style="color: #DD4A67"> my_site </span>. </li>
<li> Now run the below command to move  <span style="color: #DD4A67"> my_site </span> folder on server: </li>
 <p style="color:#34495E ;background:#F7F7F7;margin:9px;padding:2px 4px;font-weight:bold">
        $ rsync -avzhe ssh /my_site/ [email protected]:/var/www/html/
 </p>
Here 0.0.0.0 must be replaced with your server IP address. Also <span style="color: #DD4A67"> /var/www/html </span> directory is available on your server.
</ol>
After running the command you can log into your server and check that files are available there.

<h4> 3. Setup site on the new server </h4>
<p> All your local work has been finished. Now, let's set up your site at the server by simple steps: </p>
<ol>
    <li> You need a database on the server. So, now create a new database for your WordPress site using <i> MySQL or PHPMyAdmin </i> on your server. </li>
    <li> Fire up your browser and navigate to <span style="color:#3D8CB9"> http://YourServerIP/installer.php </span> </li>
</ol><br />
<p> NOTE: If you got a permission error change the owner of your project directory on the server by running the following command : </p>
<p style="color:#34495E ;background:#F7F7F7;margin:9px;padding:2px 4px;font-weight:bold">
  $ chown www-data:www:data /var/www/html/my_site
</p>
Here we have four steps for setup our site : <br />
<b> Step - 1 : </b>
<br /> Here you can see the interface of installation. You need to accept the terms and click on <b> Next </b> button.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/bc4d75a7c3-1611399527/6-Duplicator_setup_1.jpg"></figure>
<br />
<b> Step - 2 : </b>
<br /> In this step, you need to configure your database by putting the database name with user_name and password of your database. Now test the database and click <b> Next </b> button.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/be4871163c-1611399527/7-Duplicator_setup_2.png"></figure>
<br />
<b> Step-3 : </b>
<br /> Here no need to change just click the <b> Next </b> button.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/ec658e6bf1-1611399527/8-Duplicator_setup_3.jpg"></figure>
<br />
<b> Step-4 : </b>
<br /> Click on the <b> Admin Login </b> button and you see your WordPress website is live now.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/f2b91d9576-1611399527/9-Duplicator_setup_4.png"></figure>
<br />
<h5>Your Website is live now </h5>
Your WordPress site is live on <span style="color:#3D8CB9"> http://your_server_IP/my_site </span>. You just need to put your Username and Password to login to your wp_admin dashboard.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/71a0643a5f-1611399527/10-Wp_login.jpg"></figure>
<br />

<h4> 4. Redirect site to your domain </h4>
<p> Now you need to configure your site to your hostname. So whenever your visitors type your website hostname they redirect to your website. </p>

<ol>
<li> First, you need to change your <b> Wordpress URL </b> and <b> Site URL </b> from your WordPress dashboard and save this.
<br /><br />
<figure><img alt="" src="https://readybytes.in/media/pages/blog/existing-wordpress-deploy/3929ac0bbe-1611399527/11-Url_change.jpg"></figure>
<br />
</li>

<li> Now we need a virtual host on our server. For this we are going to use apache server. You just need to create a conf in <span style="color: #DD4A67"> /etc/apache2/site-available/ </span> for your website. A sample conf file for my site <span style="color: #DD4A67"> my_site.conf  </span> is given bellow : </li>
<br /> <script src="https://gist.github.com/chandrabhan11/b333a999dcf850e5e11b8118f9c20d45.js"></script> <br />
<li> Make Sure you enable the conf site. For this you need to use following command : </li>
<p style="color:#34495E ;background:#F7F7F7;margin:9px;padding:2px 4px;font-weight:bold">
$ a2ensite my_site
</p>
<li> Now restart apache server : </li>
<p style="color:#34495E ;background:#F7F7F7;margin:9px;padding:2px 4px;font-weight:bold">
$ service apache2 restart
</p>
</ol>

Now fire up your browser and navigate to https://your_host_name.com . Here you can see your site is working properly.

Congratulations !! your wordpress website is successfully deployed on the server and now you know how to move wordpress site on the server.

blog comments powered by Disqus