Home Opencart Host Opencart in google cloud for free for one year, DNS, SSL,...

Host Opencart in google cloud for free for one year, DNS, SSL, Cloudflare, SSH

Opencart Google Cloud Platform Cloudflare

This Opencart tutorial shows how to easily host Opencart in Google cloud for free for one year, set up Cloudflare, SSH to run shell scripts and commands, install an SSL certificate and redirect all non-HTTP to HTTPS URL.

Step 1: Set up Google Cloud Platform at cloud.google.com using a free Google account or Gmail account.

Step 2: Click on the Navigational Menu icon >> Marketplace >> Search for Solutions >> Type Opencart

Step 3: Select the “OpenCart Certified by Bitnami”, this Google Compute Engine package contents Apache 2.4.41, ImageMagick 6.9.8, lego 3.0.2, MySQL 8.0.17, OpenCart 3.0.3.2, OpenSSL 1.0.2s, PHP 7.3.8, phpMyAdmin 4.9.0.1, and SQLite 3.29.0.

Step 4: Click “Launch on Compute Engine”. While creating be sure to use the following for the free account
1. Compute Engine Oregon: us-west1 or Iowa: us-central1 or South Carolina: us-east1
2. Machine Type: micro (1 shared vCPU) f1-micro
Get more details at https://cloud.google.com/free/docs/gcp-free-tier
Select both HTTP and HTTPS traffic and by selecting as in the image, click Deploy.

Lots of scripts run, it creates a virtual machine instance, creating a password, setting config for opencart, setting up a firewall, and so on thus it takes some minutes for the opencart deployment and you will get the Site address, Admin URL, Admin user, and Admin password.

Now you can access the website from the site address http://34.73.130.22 for our above example and the admin section is http://34.73.130.22/admin/. Some of the suggested steps to change the temporary password, for that, go to System >> Users >> Users >> Edit user and change the password.

Step 5: Next suggested step is to assign a static external IP address to your VM instance, for that click on the Navigational Menu icon >> VPC network >> External IP addresses >> In the Type Column select the Static and give some name, with this Static IP address is created, now it will not change so we can set up the domain name to point to the website.

Step 6: Now time to set up a Domain Name to point to the google cloud DNS. For that click to Navigational Menu icon, >> Network Services >> Cloud DNS, this enabled the DNS API then create Zone, choose Zone type as Public, Zone name any, DNS name: use your domain name, DNSSEC you can use Off or On, then click create.

With the above steps, we have NS records. Now let’s add the A record. Click the Add record set button and then in DNS Name leave it blank, and in the Resource Record Type choose A and enter the Static IP that we get above in IPv4 Address (for us it is 34.73.130.22) then click create. Let’s add another record set for the www, click the Add record set button and then in DNS Name type www, and in the Resource Record Type choose CNAME and enter the non-www URL for the canonical name. Then click create.

You can see the lists of the above records as in the image. Now we use the NS record to link the domain name to our website. There are four NS records for us these are the following NS:

ns-cloud-a1.googledomains.com
ns-cloud-a2.googledomains.com
ns-cloud-a3.googledomains.com
ns-cloud-a4.googledomains.com

Step 7: Go to the domain name provider and change or add the NS records and delegate to Google Cloud servers. We use onlydomains.com for domain name registration so it looks like below:

After some minutes the site in the Google Cloud is shown, sometimes it may take up to 24hours as well.

Step 8: Now let’s add an SSL Certificate and set up an SSL Certificate for the website. Go to Menu Navigation icon >> Compute Engine >> VM instances >> then click SSH and shell script window is opened and run following shell script, be sure to change to your email and to your domain name and click Y for all 🙂

sudo /opt/bitnami/letsencrypt/scripts/generate-certificate.sh -m webocreation.com@gmail.com -d dpsignadvertising.com -d www.dpsignadvertising.com

Now redirect all HTTP to HTTPS for that let’s edit the virtual host file. Use the following script:

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

It will open the file, then paste the following code in it.

RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/(.*) https://www.dpsignadvertising.com/$1 [R,L]

It looks like below:

Now restart apache by the following command:

sudo /opt/bitnami/ctlscript.sh restart apache

With these steps, SSL certificates are created and all non-HTTPS are redirected to HTTPS URL.

Step 9: We see the Bitnami Banner Ad at the bottom right corner, let’s remove it.

Run the following command in SSH

sudo /opt/bitnami/apps/opencart/bnconfig --disable_banner 1
sudo /opt/bitnami/ctlscript.sh restart apache

With these commands, the Bitnami Banner Ad is removed.

Step 10: Let’s add the Cloudflare CDN for the Opencart website to increase performance using a CDN (Content Delivery Network). Go to cloudflare.com and signup for a new account and then add the website URL and click continue and you will get new Cloudflare’s nameservers like:

Now again need to go to the domain registrar and need to delegate to Cloudflare nameservers and remove the google cloud servers. For us it looks like below:

With these changes, Cloudflare will start protecting our site. Sometimes it may take up to 24hrs, but Cloudflare will notify once it is active

In this way, you can easily host the Opencart website in Google Cloud Platform, setup the DNS and your website URL in google cloud DNS, log in with SSH, create an SSL certificate, install it and redirect all to HTTPS, and configure the Cloudflare for the website for better performance. Hope you liked this post, let us know if you have any questions or suggestions, please subscribe to our YouTube Channel for Opencart video tutorials. You can also find us on Twitter and Facebook. Enjoy!

Others:

1 COMMENT

  1. The only problem that OpenCart 3.0.3.2 is not usable, it’s full of bugs. I have 4 projects running on it, but…
    – FedEx
    – USPS,
    – Session,
    – PayPal,
    etc. NOT WORKING
    – Admin is not usable for big inventory
    – MyISM – cannot handle all requests to the database if number of products 10-15K+

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version