Google Cloud VM Instance Setup with Ubuntu and XAMPP PHP Server
Wall Script
Wall Script
Tuesday, July 30, 2019

Google Cloud VM Instance Setup with Ubuntu and XAMPP PHP Server

Google cloud platform is a cloud computing service and a perfect alternate for Amazon Webservices. Nowadays most of the top companies are moving towards Google services for better results. Google cloud platform is offering a $300 free trial for one year. This post is about how to set up VM instances with firewall rules in addition to creating a XAMPP server with Ubuntu operation system. This is almost similar to my previous article about the Amazon EC2 setup. Try this and enrich your side projects.

Google Cloud VM Instance Setup with Ubuntu and XAMPP PHP Server


Getting started with Google Cloud Platform Free Tier

Step 1
Search for Google Cloud Free Tier
Google Cloud Free Tier

Video Tutorial


Step 2
Hit the Try Free button
Google Cloud Free Trial

$300 Credit for free
Google Cloud Free Trial

Step 3
Choose your country.
Google Cloud Free Trial

Step 4
Accept the terms
Google Cloud Free Trial

Step 5
Add the payment details. This will not charage, until one year free trial.
Google Cloud Free Trial

Step 6
Go to Billing and cross verify the free tier detials.
Google Cloud Free Trial

Getting started with Google Cloud VM Instance

Step 1
Google Cloud console for top product. Now selec the Computer Engine
Google Cloud Free Trial

Step 2
Create the VM instance.
Google Cloud VM instance setup

Step 3
Here you have to provide the instance Name, Region and Zone. Machine type choose base on your need. I would suggest you to choose the standard(3.75 GB) or small(1.7 GB) memory instances.
Google Cloud VM instance setup

Step 4
Choose The Operating System. This post is about Ubuntu stetup.
Google Cloud VM instance Operating system

Step 5
Firewall allow HTTP and HTTPs traffic and click the Create button.
Google Cloud VM instance Operating system

Step 6
Instance has been created.
Google Cloud VM instance Operating system

Google Cloud Static External IP Address
Default instance external IP address is not permanent. You have to reserve the static IP address for DNS(Domain Name Server) settings.

Step 1
Go to Networking -> External IP Address
Google Cloud Static IP Address

Step 2
Now change the type Ephemeral to Static
Google Cloud IP Address

Step 3
You have to provide the name and description for the reference to Reserve the static IP address.
Google Cloud IP Address

Step 4
This automatically map with existing instance. If you have multiple instances, just choose by click on the In use by
Google Cloud IP Address

Connecting the Instance with SSH

Step 1
Go to the instance and click the SSH button under the Connect.
Google Cloud SSH Connect

Step 2
Browser lanuches a cloud terminal with SSH connect.
Google Cloud SSH Connect

XAMPP Installation Commands for Ubuntu

Download XAMPP for 64 bit
wget https://www.apachefriends.org/xampp-files/7.0.23/xampp-linux-x64-7.0.23-0-installer.run

Make Execute Installation
sudo chmod +x xampp-linux-x64-7.0.23-0-installer.run

Run Installation
sudo ./xampp-linux-x64-7.0.23-0-installer.run
Google Cloud SSH Connect

XAMPP instructions
Select the components you want to install; clear the components you do not want to install. Click Next when you are ready to continue.
XAMPP Core Files : Y (Cannot be edited)
XAMPP Developer Files [Y/n] : Y
Is the selection above correct? [Y/n]: Y

Installation Directory
XAMPP will be installed to /opt/lampp
Press [Enter] to continue:
Do you want to continue? [Y/n]:Y

Run XAMPP
sudo /opt/lampp/lampp start

Google Cloud SSH Connect

XAMPP Access Forbidden
Open your browser and access http://IP-ADDRESS/ you will find this Access forbidden screen.
Launch instance

XAMPP Configurations
Edit XAMPP configurations.
vi /opt/lampp/etc/extra/httpd-xampp.conf

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

to

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
Allow from all
Allow from ::1 127.0.0.0/8 \
fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
fe80::/10 169.254.0.0/16
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

Restart XAMPP
sudo /opt/lampp/lampp restart

Security Settings
sudo /opt/lampp/xampp security

XAMPP: Your XAMPP pages are NOT secured by a password.
XAMPP: Do you want to set a password? [yes]
XAMPP: Your XAMPP pages are NOT secured by a password.
XAMPP: Do you want to set a password? [yes] no
XAMPP: MySQL is accessable via network.
XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] yes
XAMPP: Turned off.
XAMPP: Stopping MySQL...ok.
XAMPP: Starting MySQL...ok.
XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Password:*******
XAMPP: Password (again):*******
XAMPP: Setting new MySQL pma password.
XAMPP: Setting phpMyAdmin's pma password to the new one.
XAMPP: MySQL has no root passwort set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Write the password somewhere down to make sure you won't forget it!!!
XAMPP: Password:*******
XAMPP: Password (again):*******
XAMPP: Setting new MySQL root password.
XAMPP: Change phpMyAdmin's authentication method.
XAMPP: The FTP password for user 'daemon' is still set to 'xampp'.
XAMPP: Do you want to change the password? [yes] no
XAMPP: Done.

PhpMyAdmin
Access PhyMyAdmin at http://IP-Address/phpmyadmin/
Launch instance

Domain Settings
If you own a domain address, go to domain DNS(Domain name settings). Add host value @ points to IP-Address
Launch instance


Activate for Unlimited Access of GCP
You will find the following notification to activate.

Activate the unlimited access to use features like Static IP, Firewall rules etc.
Google Cloud IP Address

Upgrade your accout.
Google Cloud IP Address

Find the billing information.
Google Cloud IP Address

Custom Firewall Settings
For enabling custom ports for external usage.

Go to Network -> Firewall Rules
Google Cloud Firewall Setting

Here you will find the default internal rules.
Google Cloud Firewall Setting

Create a new rule.
Google Cloud Firewall Setting

Choose Specified protocals and ports and Source IP range 0.0.0.0/0
Google Cloud Firewall Setting

Firewall rule has been created.
Google Cloud Firewall Setting

Edit the rule and modify the protocals and port numbers. Here I enabled 80 for HTTP and 443 HTTPs. But we already enabled by default with VM instance. This is just an example to understand.
Google Cloud Firewall Setting

This will show the port numbers in following way.
Google Cloud Firewall Setting

You can apply the firewall rule at VM instance details at Network tags. Here include the custom Firewall tag name.
Google Cloud Firewall Setting


web notification

4 comments:

  1. Very good post. But can't choose between AWS and Google cloud. Not sure which is the best for my needs.

    ReplyDelete
  2. Thanks for the update easy setup. I set up with the XAMP PHP server without any hazard. I think it is so much useful for all & we may hope that we get same type of post continuously.

    ReplyDelete
  3. Very helpful post. I have done the configuration as per the post & it's working fine.
    But can you help me to create sub domain.

    ReplyDelete

mailxengine Youtueb channel
Make in India
X