Hosting: moving to Google Cloud Platform

This entry will cover on the process of moving out an entire site from old hosting to Google Cloud Platform (GPC). It is assumed that:-

  1. You have SSH access to old hosting account
  2. You already create your VM with GPC
  3. You already install web server/apache & mysql/phpmyadmin on that VM

Step 1

The initial phase is to zip your site files. Access to the old hosting via SSH and zip them:

zip – r website_folder.zip website_folder/

Step 2

The zipped file then can be downloaded via FTP access or any file transfer you prefer, the main point is to move website_folder.zip to GPC.

One easy alternative is to move the zipped file to a downloadable location such as:

mv website_folder.zip website_folder/

Then from GPC SSH:

cd /var/www

wget http://www.website_folder.com/website_folder.zip

Then on your old hosting SSH:

rm website_folder/website_folder.zip

Step 3

Unzip the files on your GPC:

cd /var/www

unzip website_folder.zip

Notes: if there is an error such as “command not found”, just install it.

sudo apt-get install unzip

Now after unzipping the files you will get website_folder in the current path, such as:

/var/www/website_folder

Now change the ownership:

chown -R www-data:www-data website_folder

Step 3

Let’s make a copy of database from old server. Cpanel users will be able to do this via ‘export’ function in phpmyadmin then download the SQL file, name it as website.sql

Step 4

Import the database to your GPC. Go to your VM phpmyadmin, create a database, and do the import function.

Step 5

Update apache configuration file to let it know where your files are located at.

At GPC SSH:

cd /etc/apache2/sites-available/

Create a file with this content:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName website.com
        ServerAlias www.website.com
        DocumentRoot /var/www/website.com

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Name it website.com.conf

Then enable it:

sudo a2ensite website.com.conf

sudo service apache2 restart

Step 6

Now point your domain DNS to GPC external IP address.

After the the DNS propagation done, the website should be served from GPC already.

Prev PostDividen ASB 2018 dan 5 tahun sebelumnya
Next Post#khabarbaik - pelan pasca bayar serendah RM19 dari Unifi Mobile

Leave a reply