How To Deploy Your Mobile App Backend In Google Compute Engine (GCE)
Integrating Google Compute Engine for your mobile app backend data is the best thing for success of your mobile app.
1# Go to the Compute Engine and log in using your gmail id.

2# Then, Go to My console (top right corner) this shall land you to the ‘Getting Started’ page. It shall display different information regarding 'starting with Google cloud'.
- Try compute engine
- Create Google Cloud Storage Bucket
- Try app engine
- Use Google APIs
- Create Cloud SQL instance
- Documentation for more info
You shall be dealing with this page in step no. 2
3# Create Project in Google Compute Engine
- Select “create a project” option from the drop-down menu and Select a project from the given header.
- Now, add the project name. There are two responsive checkboxes which let you agree to the terms and conditions, and second to subscribe to the mailers

4# In this step, we need to create the instance of the virtual machine where we want to deploy the application.
- For the payment part – Google provides the credit of $300 with the 60 days trial period to explore the Google cloud platform.
- Google Compute Engine adopts ‘Pay as you go’ model. Therefore, you shall be charged only for the services you render in the form of the instance requests.
5# Creating Virtual Machine Instance
- In the Cloud Platform Console -- go to the VM Instances page.
- Go to the VM Instances page
- Click the Create Instance button.
- In the Boot disk section, click Change to start configuring your boot disk. You have the option to select the machine type based on the expected server requests.
- In the Preconfigured image tab, choose the Debian 8 image or any other which matches your requirement on which you want to deploy backend e.g. Ubuntu 14.04 LTS and so on.
- Click Select.
- In the Firewall section, select Allow HTTP traffic. If you want to allow secure connection than allow HTTPS traffic too.
- Click the Create button to create the instance.
Just wait for some time for the instance to start up. Once ready, it is listed on the VM Instances page with a green status icon.
6# Connect with your Instance
Now the task is to connect the data to the instance you just created
- In the cloud platform console goes to VM instance page.
- In the list of virtual machine Instances, click on SSH button from the row of Instance to which you want to connect.
- It gives you a terminal window for interacting with your Linux Instance.
All the required setup can be done over here in the Terminal window
Here are some of the ways to connect the Google Compute Engine
- Connect from a browser (Same step as above explained)
- Connect to an Instance using Gcloud
- Connect using the SSH on Linux or Osx workstation
- Connect using Putty on Windows workstation.
Check how to connect to the instance over here.
7# Now, you need to run the required setup to upload the backend on GCE. Below are the steps which you require following for uploading the PHP backend.
Step 1: Install Apache and PHP on your instance
Sudo apt-get update Sudo apt-get install apache2 php5
Step 2 : Test Apache & PHP
i. You must have an external IP address of the Instance. You can get this from the VM instance page in Cloud Platform Console.
http://[YOUR_EXTERNAL_IP_ADDRESS]
sudo sh -c 'echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php'
http://[YOUR_EXTERNAL_IP_ADDRESS]/phpinfo.php
1. In the Cloud Platform Console, HTTP traffic is allowed for your instance.
2. The URL uses the correct IP address and file name.
Step 3 : Install MySQL on your instance
v. Install MySQL and related PHP Components
sudo apt-get install mysql-server php5-mysql php-pear
vi. Configure MySQL. You should run the mysql_secure_installtion
command to improve the security of the installation.
sudo mysql_secure_installation
Step 4: Install PhpMyAdmin to handle the database of MySQL and follow the basic steps asked during the setup e.g. password for the database access and so on.
sudo apt-get install phpmyadmin sudo apt-get update
Step 5 : Test & Verify PhpMyAdmin. Before going to test PHPmyadmin follow the steps to change the config file.
vii. Open apache.conf
using your favourite editor, mine is vi
:)
sudo vi /etc/apache2/apache2.conf
viii. Then, add the following line:
Include /etc/phpmyadmin/apache.conf
ix. Test the PHPmyadmin. You must log in to access the database using the initial username and password.
The default username would be root, and password is the one which you have set during the installation of PHPmyadmin.
http://[YOUR_EXTERNAL_IP_ADDRESS]/phpmyadmin
Step 6: By default the Mod rewrite is disabled in apache and before we start generating the actual URL rewrites, we need to activate the Apache mod_rewrite
module to control them.
sudo a2enmod rewrite sudo service apache2 restart
Step 7: Once the module is enabled, we can set up our URL rewrites by creating a .htaccess file in the backend directory.
x. A .htaccess file is a way to configure the details of your backend or website without needed to alter the server config files.
xi. We can create the .htaccess site in a text editor without giving any name to file and extension .htaccess.
Step 8: Permit the changes in .htaccess file
xii. Allow the .htaccess file to override standard configurations by starting by opening the configuration file.
sudo vi /etc/apache2/sites-available/default
xiii. Inside that file - find the below-mentioned section, and change the line that says AllowOverride from None to All. The section should now look like this:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
xiv. You are required to restart apache once you save and exit that file.
.htacess files shall be available for all of your sites.
sudo service apache2 restart
Though done with the mandatory server setup, we are yet to upload the files on Instance.
However, before uploading it, we need to update the change required for the database connection.
8#. Transferring file to instance
There are multiple ways to transfer the file we can use any based on our workstation.
i. Transferring the file using Gcloud
ii. Transferring the file using the browser on Linux or OSX workstation
iii. Transferring the file using SCP on Linux, or OSX workstation
iv. Transferring the file using WinSCP on Windows workstation
Moreover, this is it; you have successfully transferred the file over the Instance built in the server. Now it has become easy to set up your cloud computing space with Google Computing.