arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Corrected - refer last post] Migrate Your Website to New VPS Host ( Ubuntu/Debian )
#1
Hello Friends, I am new in the linux world. I don’t know much about Linux packages and other applications. I have a blog hosted on my VPS. A few days ago I wanted to migrate to a new VPS. I searched google about the transfer web from one host to a new one. I found some but failed to transfer with those methods. In searching, I found information that we need to export our database and directory and transfer it to a new host. I transferred my website successfully to a new host. I am going to share the method I used to transfer.
First of all, you need to export your website database. You can export it via Phpmyadmin. Actually, I don’t use Phpmyadmin so I export/import database via Terminal.
If you have Phpmyadmin export it. If you don’t, use the following method to export the database.

Database Export via Terminal


mysqldump -u [username] -p [database name] > [database name].sql

The exported file can be downloaded from the root folder or the user folder you are logged in.

First of all, go check if the database is exported or not. After confirmation download it to your PC.

The database backup is completed now. Lets back up the website directory. The directory has a high file size. Downloading it via SFTP client is very difficult so I use a different method. I use Google Drive. I will zip the directory and upload it to google drive. 
We need to install google drive.

First of go to the root directory with the following command


cd ~

Now download the google drive


wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download

 
After the download is completed we will rename the downloaded file. Use the following command to rename the downloaded file.
The downloaded file will have the name “ uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE “


mv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive

We have renamed the file. Let's give the execution permission


chmod +x gdrive

Now we have to install this to our usr directory. Use the following command to install.


sudo install gdrive /usr/local/bin/gdrive

During this installation, we will have to provide our google email. It will also require email confirmation. The terminal will give us a link, we will have to allow the application to access our google drive account.

We are done, the installation of google drive is completed.

Let's compress the website directory.

If you don’t have already installed zip install it first.


zip  -r filename.zip /path/folder


The compressed file is stored in the same directory or the user directory you are logged in. Now we will upload this zip file to our google drive.

Use the command gdrive upload to upload the file.


gdrive upload filename.zip

The file will be uploaded to your google drive account. Now let's restore it to our new host.

Logout of your terminal and login to your new host. 

First of all, we will restore our database. I use the terminal to restore but you can also restore it with Phpmyadmin.

I use the terminal to restore the database.

First of all login to your MySQL and create a new database with the following command.



CREATE DATABASE newdb;

After creating log out of your MySQL with the simple exit command. Now upload the downloaded .sql database file to the root directory using a SFTP client.

Use the following command to restore the database


mysqldump -u [username] -p [database name] < [database name].sql


Database restore is completed now let's restore our website directory.
Download the file we uploaded on google drive and unzip it.
There are two methods to download the file from google drive, you can not directly download from google drive. If you want to download you need to install gdrive on your new host. There is an alternate method, I uses. 
The method I use is to move zip file from google drive to MediaFire is MultCloud. It is very easy to move your files to mediafire from google drive.But it may be risky.So do it on your own risk. Register at MuliCloud and add your google drive and mediafire account to share files. I simply share my .zip file to mediafire account and download it with the simple command


wget https://mediafire.com/example.zip
After downloading move your file to /var/www/ and unzip using the command 


unzip example.zip

We have successfully transferred our website files and database to the new host. Now you just have to edit your website configuration and set its DocumentRoot and enable your site.
Most of the webmaster's know about the Apache site configuration but here is simple information for those who are a newbie.

The website configuration file is stored in " /etc/apache2/sites-available "
So you will have to be in the directory, use

cd /etc/apache2/sites-available

Here you will have to create a new configuration file. Simply use the nano command to create a new .conf file.

nano mysite.conf

and paste the following code, save and exit.
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName yourdomain.ext
   ServerAlias www.yourdomain.ext
   DocumentRoot /var/www/example    ( Update this to the directory we have downloaded )
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now we have to enable our website use

a2ensite mysite



If you have any question feel free to ask.

Thanks

regards

Rehan


Messages In This Thread
[Corrected - refer last post] Migrate Your Website to New VPS Host ( Ubuntu/Debian ) - by Rehan - 08-22-2019, 08:47 AM


person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting