Comprehensive Guide for Magento 2 Installation On GCP

Comprehensive Guide for Magento 2 Installation On GCP

In this post, we are going to see the steps and required setting for Magento 2 Installation on any cloud platform. In the video, I recorded for Google Cloud Platform, but you can use these steps the same as it is for any other cloud services.

Magento is an Open Source specially dedicated e-commerce Content Management System(CMS) for Online Store or Online Shopping websites.

If you thinking for Readymade Best Cloud Servers, Personally Recommend Below Hosting Provider. Try This. Very Cheap and Best Service Providers in India. As Magento Requires min 2GB of RAM to perform Best

Comprehensive Guide for Magento 2 Installation On GCPComprehensive Guide for Magento 2 Installation On GCP

Magento 2 Installation is very expensive but has very good optimized in Search Engine Optimization(SEO) Point of View. I personally recommend being aware of Magento CMS or get the minimum knowledge of Magento OpenSource Platform. Like manually hosting on cloud computing engine(AWS, GCP or Digital Ocean or Azure etc.), customizing modules, blocks and pages, Customizing multi-store website for different locations etc.

This Helps You: Hosting WordPress on Google Cloud

Magneto is very dynamic in nature and has a very complex coding structure. You should have minimum knowledge of PHP or XML if you want to be good in Magento. But in my opinion, just understand the structure of Magento architecture and design. This is more than enough to learn and manually customization of open source code.

On my YouTube channel, I have shared How to host a Magento 2 on Google Cloud compute instance, accurately. Just follow those steps as shown in that video. Don’t do or miss any Linux commands, otherwise, you will get errors.

Step by Step Guide for Magento 2.3 Installation On Google Cloud Platform

Hello Friends, Magento 2 is very Popular E-commerce CMS for Online Business Presence. It is a very dynamic e-Commerce platform with ultimate ...

If you are familiar with Ubuntu 18.04 Linux commands and Magento documentation, this will be a piece of cake for you.

In this post, I just want to expose about relative commands and the usage of it.

Follow the steps as shown in video with below command line.

back to menu ↑

Magento 2 Installation On Google Cloud Platform:

1. Required Settings Before installing Ubuntu 18.04

5% off on .COM domain

Comprehensive Guide for Magento 2 Installation On GCP

As usual login into your Google Console, find the Compute Engine Section in the dashboard side panel. From that, select VM instance and Create and New virtual machine with your own or any name of default 3.75GB of RAM and 10GB of SSD hard drive for storage. Choose as per your requirement.

As Magento 2 Installation requires minimum 2GB of to work efficiently on Backend/Server-side execution. You may extend the SSD Hard disc with min 10GB to 30-40GB as per your business requirement. Then Create the Virtual Server Magento 2 Installation.

Remember Don’t forget to allow All HTTP and HTTPS requests by checking the box in Firewall Section before creating an instance.

Allowing Firewall Section - Magento 2.3 Installtion on GCP
Allowing Firewall Section – Magento 2.3 Installtion on GCP

After Creating an instance, you will get dedicated IP for your virual server. Copy it and strore it safely.

If you are using Cloudflare CDN, you need to modify your pointing domain IP to the obtained new one IP. Just copy from GCP to your Cloudflare domain dashboard.

After that click on SSH option, showing on side of obtained IP of GCP. Then you will get Black coloured SSH prompt of Google Cloud Bash. Before entering any commands, just click on SSH’s small side strip (“view gcloud command“) and copy that all command, paste it in black coloured SSH bash terminal. and hit enter. I have shown in my video you can watch it for reference.

Getting gcloud command for starting a SSH terminal

After hit Enter two times to get the root location for Magento 2 Installation at the HTML directory location for further software installation

From this onwards Just copy and paste the following commands for a successful installation.

2. Installing Apache2 Server on Ubuntu 18.04

sudo apt update && sudo apt install apache2

3. Configure Firewall

sudo ufw allow OpenSSH
sudo ufw allow in “Apache Full”
sudo ufw enable

Press “y” and hit enter

If you want to check the “ufw status”, run the following command.

sudo ufw status

4. Installing Repositories

This command is necessary to get installed required repository for future Magento 2 Installation and other PHP compatible repositories.

sudo add-apt-repository ppa:ondrej/php

Again run the Ubuntu updating command as follows to get up to date packages and repositories.

sudo apt-get update

Next Step is to modify the “000-default.conf” available in apache2 directory by using below command.

sudo nano /etc/apache2/sites-available/000-default.conf

Add below content as it is in the top section of the opened file.

<Directory “/var/www/html”>
          AllowOverride All

sudo nano /etc/apache2/apache2.conf

Add below line to the last line of the page

ServerName your_server_IP_address

Enter obtained IP address from your GCP vm instance.

sudo apachectl configtest
sudo a2enmod rewrite
sudo systemctl restart apache2

5. Magento 2 Installation – Installing PHP 7.2

As Magento recommended for Magento 2 Installation, to install PHP version 7.2.X or 7.3 only as previous versions of Magento was supported previous versions of PHP, and this time they were deprecated.

For this, we have run following command to install required PHP extensions which are mandatory for Magento 2 installation. So that we combined all PHP extension installation commands in one sentence by minimising further line of commands.

sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-soap php7.2-bcmath php7.2-xml php7.2-mbstring php7.2-gd php7.2-common php7.2-cli php7.2-curl php7.2-intl php7.2-xmlrpc php7.2-json php-imagick php7.2-zip zip unzip -y

Hit enter and wait for 1-2 min for all installation. Press yes or y whenever is needed.

sudo nano /etc/apache2/mods-enabled/dir.conf

Enter the “index.php” in the first place of obtained editor file. As shown below.


Press ctrl+x then press y and hit enter to exit from successfully saving the dir.conf file of apache2.

Restart or Reload Apache2 Server by following command.

sudo systemctl restart apache2

6. Install MySQL

sudo apt update && sudo apt install mysql-server

Check the running status of installed MySQL by following command

sudo service mysql status

7. Installing MySQL Security

sudo mysql_secure_installation

Hit Enter, is asks you for strong password input, then press “2” for strong password and press “y” wherever is needed till last.

If you want to check the version of installed MySQL then run the following command.

sudo mysqladmin -p -u root version

8. Installing phpMyAdmin

sudo apt-get install phpmyadmin php7.2-mbstring php7.2-gettext -y

Restart or Reload Apache2 Server by following command

sudo systemctl restart apache2

9. Creating SQL Database, database user and password

sudo mysql

Replace “dbname” with your desired database name


Creating a database user with a strong password. So that, Replace “newuser” with your desired database-username and “password” with a desired strong-password.

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

Granting or allowing all Privileges

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

Restart the Server

sudo systemctl restart apache2

#Bonus Step – To Secure phpmyadmin

If you want to secure your PHPMyAdmin with anonymous URL or link use below command and edit that file as shown in the video. Just replace the “alias” link line.

sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Alias /newlogin_name /usr/share/phpmyadmin

Press ctrl+X, y and hit Enter to Save and Exit

Restart or Reload the Apache2 Server

sudo service apache2 reload

10. Create a Magento user

Creating a new user is mandatory for security reason. It helps your server protected from hacking and brute force attacks, modification to your root directory and core Magento files. So that by creating a new user with your desired name and giving the required superuser permission is an important task. Follow the following commands. This also avoids further Magento 2 Installation errors.

sudo adduser yuvi

Giving superuser permission to created new user

sudo usermod -g www-data yuvi

Changing ownership and writing permission to created new user.

sudo chown yuvi:www-data /var/www/html/

11. Magento 2 Installation – Installing Composer

This is very important to use a composer for direct online, server-side Magento 2 Installation. This minimises our Uploading and downloading work and time via Filezilla or any other mode of installation.

Magento community also recommends about Magento 2 Installation for required extensions only by this composer method. This is very easy and simple. Just copy and paste it.

sudo curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

Then Switch to the installation directory of Magento 2 i.e. be in a main public_html directory of your server where you want to install Magento setup files.

Just run below command.

cd /var/www/html

Switch to the Created new user

su yuvi

Remove the present “index.html” file available in that directory. Without this Magento 2 setup can’t get installed or may give you an error.

rm index.html

12. Magento 2 Installation – Downloading Magento

You must have registered to the Magento portal and find the public key and secret key in your profile section. This alphanumeric key is used as a username and password for Magento 2 Installation. Just copy and paste it as shown in the video.

composer create-project –repository-url= magento/project-community-edition .
Note: Above command, don’t forget the given dot[.] It is necessary, as it denotes to install all necessary downloadable files in a current directory. Otherwise, it can’t get installed.

From Magento website, login in it, get the Public & Private keys as Username and Password for further installation and press “y” for next step.

Wait for 5 to 15 min to get the installation of all setup files from official Magento site.

13. Modifying and Enabling some necessary permissions

find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R :www-data . && chmod u+x bin/magento

Don’t miss any word, copy the entire line of command, we combined 3 lines of command in one line. This saves our further steps.

14. Modify the php.ini file of php7.2 and .htaccess

For modification php.ini run the following command

sudo nano /etc/php/7.2/apache2/php.ini

Modify or Replace the below contents of value with given below value respectively.

memory_limit = 2Gupload_max_filesize = 300Mmax_file_uploads = 100zlib.output_compression = Onopcache.save_comments=1date.timezone = Asia/Kolkata

To Modify or Replace the below contents of value with given below value respectively for .htaccess

nano .htaccess

Restart or Reload the Server

sudo systemctl restart apache2

15. Installing from Browser

Enter your domain name. After that you will get installation page of Magento 2 with latest version. Follow the instructions as shown on the page. Before final installation it will ask you about your database name, database user name and password, as you created, after the installation of phpmyadmin.

Enter your required time zone, currency setup and language you desired for. Then Enter the admin user name, transactional email ID and admin password.

After Successful installation, it will redirect you to new page where you should choose your desired admin URL. It should be https://your_domain_name/admin_6sjsh.

If you want o change the admin URL, you should choose non-guessable and anonymous alphanumeric admin URL to protect from Hacking and Brute Force attacks.

Then Click Finish Install. Wait for 2-3 min to installing the final setup. After Successful installation copy, all displayed data of that page in txt format or wherever you want for further need. This is your final Magento 2 Installation setup.

16. Necessary Settings for Magento Usage

Login into your admin panel and click on “Allow” to improving Magento’s customer targeted optimization. It helps to Magento company to get any errors, bugs or any further set up improvement.

After this, get back to the GCP’s terminal window and run the following command for installing and enabling the cron job.

bin/magento cron:install

If you get any message like “cron running error for indexers”, run following command to overcome from that.

bin/magento cron:run –group index


bin/magento indexer:reindex

17. Installing Sample Data

For installing Sample Data, run the following commands, as it is

bin/magento deploy:mode:set developer
rm -rf generated/metadata/* generated/code/*
bin/magento sampledata:deploy

Then, it will ask username and password, enter previously entered Username and Password when you was installing Magento 2 Setup.

bin/magento setup:upgrade

All Setup and Sample Data Installation is Done.

Congratulations, You have successfully installed your first Online Store with Magento 2.3.X.
back to menu ↑

Watch Video – Do it as ts is

Step by Step Guide for Magento 2.3 Installation On Google Cloud Platform

Hello Friends, Magento 2 is very Popular E-commerce CMS for Online Business Presence. It is a very dynamic e-Commerce platform with ultimate ...

In coming post we are going to see how to update themes, New SEO, Facebook and Google Tag Manager Extension using composer only. So, Stay tuned and subscribe our email list to get notified for upcoming posts.

Thanks for watching my video and reading this post.

Up to 50% Off On Web Hosting

Comprehensive Guide for Magento 2 Installation On GCP

5% off on .COM domain

Comprehensive Guide for Magento 2 Installation On GCP

15% Off .IN Domain

Comprehensive Guide for Magento 2 Installation On GCP
  1. Heya just wanted to give you a brief heads up and let you know a few of the
    pictures aren’t loading correctly. I’m not sure why but I think its
    a linking issue. I’ve tried it in two different web browsers and both show the same outcome.

  2. I really love your blog.. Very nice colors & theme. Did you develop
    this website yourself? Please reply back as I’m hoping to create my very
    own blog and would love to learn where you got this from or exactly
    what the theme is named. Kudos!

    • Yes. I customised this my small blogging website. If you want to get this theme, please visit this link. It is a paid version, but it has inbuilt lots of features and specially developed for Affiliate Marketing Blogging website. For more details reach me at [email protected]

  3. Thank You it’s very helpful

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.