Install Magento 2, SSL and Apache2 on Google Cloud

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, avr: 4.40)

Magento is an e-commerce platform built with PHP and it’s an open source technology which provides online merchants with a flexible shopping cart, content and functionality of their online store. This tutorial demonstrates step by step how to install Magento 2, SSL and Apache2 on Google Cloud

Google Cloud Platform (GCP) offers pre-defined templates that you can use to deploy common solutions with Deployment Manager. These templates are offered as part of GCP Marketplace and can be found in the Google Cloud Platform Console, one of them install Magento, SSL and Apache2


Before starting with this guide, make sure you are able to use the Google Cloud Platform Console and the gcloudcommand-line tool SSH. on this tutorial we will use testing subdomain

Step 1: Install Magento 2

There are multiple templates versions of Magento on Google Cloud Marketplace, on this tutorial we are going to use Magento 2 Certified by Bitnami, let’s install it

Go to Left Sidebar Menu ➝ Marketplace ➝ On input search box type “Magento”  then click on Magento Certified by Bitnami

You will be directed to deploy form, set VM name as your own, choose Instance zone location and let others default value

  1. Set name for deployment (you may change with your prefer name)
  2. Select zone location (recommended choose the closest location with your target country)
  3. Machine type it recommended min small 1 share CPU
  4. Boost disk type recommended SSD
  5. Deploy (let others default value)

Step 2: Reserve a Static IP Address (Optional)

A static/external IP address is an external IP address that is reserved for your VM Instance or other projects. You can reserve that IP address so that only your project can use it. Reserving static IP is an Optional you still can use external (dynamic) IP provided by default when creating a project.

Go to Left Sidebar Menu ➝ VPC network ➝ External IP Addresses ➝ On the above menu click “RESERVE A STATIC ADDRESS”

  1. Set name for your reserve static IP
  2. IP Type select Regional
  3. On Region select the same region as your VM Instance Region already deployed on step 1
  4. Attached by selecting VM Instance name
  5. Reserve

Sometimes it does not directly change the IP address on Apache 2, Changes made in the Apache2 configuration file will not be applied until the command to Restart

sudo /opt/bitnami/ restart apache

Step 3: Configure Domain to IP Address

Got to domain provider to create or add A record and pointing to static IP address

  1. Your domain name (On the picture we used a subdomain for testing)
  2. Set IP address
  3. Save

DNS or IP Address changes usually take 24 to 48 hours to propagation for fully start working

Step 4: Update Hostname

Magento requires updating the IP address/domain name if the machine IP address/domain name changes. The bnconfig tool also has an option which updates the IP address, called –machine_hostname

sudo /opt/bitnami/apps/magento/bnconfig --machine_hostname YOUR_DOMAIN

Step 5: Install SSL on Magento

SSL (Secure Sockets Layer) is a standard security protocol for establishing encrypted. If you don’t have own SSL certificate and want to enable HTTPS (SSL/TLS) on the website, we recommended to use Let’s Encrypt, it is a free, automated, and open certificate authority (CA)

Go to Left Sidebar Menu ➝ Deployment Manager ➝ Deployments ➝ Click on your project name

  1. User and Password information for your Magento Admin
  2. Click on SSH to install SSL

To install SSL Let’s Encrypt certificate, for this example we used both www and non-www and (Don’t forget to change it with your domain name and email address)

sudo /opt/bitnami/letsencrypt/scripts/ -m [email protected] -d -d

If prompted confirmation type Y and ENTER to continue

Restart the Apache2 web server

sudo /opt/bitnami/ restart apache

You should now be able to access your application using an HTTPS URL, let’s see on url SSL Let’sencript worked perfectly and on the page showed Bitnami banner icon

Step 6: Configure Redirect Http to Https

The default Apache virtual host file Bitnami is in directory /opt/bitnami/apache2/conf/bitnami/bitnami.conf  modify these file use nano editor

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

Add this code RewriteRule ^/(.*) https://(www).%{SERVER_NAME}/$1 [R,L] if you don’t want www just remove it

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]

Press Ctrl/Cmd + X and then press Y and ENTER to save changes

Changes made in the Apache2 configuration file will not be applied until the command to Restart

sudo /opt/bitnami/ restart apache

Step 7: PHP File Upload Limit

The default PHP file configuration directory /opt/bitnami/php/etc/  we need to modify a file php.ini

sudo nano /opt/bitnami/php/etc/php.ini

To edit these file you may find or use Cmd/Ctrl W to search

post_max_size = 100M
upload_max_filesize = 100M

Press Ctrl/Cmd + X and then press Y and ENTER to save changes

Changes made in the Apache2 configuration file will not be applied until the command to Restart

sudo /opt/bitnami/ restart apache

Step 8: How to Remove Bitnami Banner Logo (Optional)

The Default page is including Bitnami banner Logo it’s useful links to documentation. If you want to remove this banner you have to set disable bnconfig to be True, /opt/bitnami/apps/APPNAME/bnconfig --disable_banner 1 to do this use the command below

sudo /opt/bitnami/apps/magento/bnconfig --disable_banner 1

If this tutorial could help you, please rate above Star button rating and share to help others find it! Feel free to leave a comment below.

Recommended For You

About the Author: Axfod is a site Online publisher for collection of guides and tutorials about Internet Technology