DEV Community

Krishnakanth
Krishnakanth

Posted on

How to host a static website for free using Google Cloud Platform

What is Google Cloud Platform ?

Google Cloud Platform is a data center infrastructure that Google uses for their products like Youtube, Search, etc. GCP is one of the popular cloud services especially for startups and websites since its price is cheaper and affordable than other cloud computing providers. Other popular cloud service providers are Amazon Web Services, Microsoft Azure, Oracle and IBM Cloud.

Google provides 300$ credit for free to new users. We can use this to host a new html site for free.

Steps for hosting a website in Google Cloud Platform :

  1. Signup for free quota from Google cloud website https://cloud.google.com/ using your google account and validate credit card details.

Signup

  1. Then Create a project by giving your needed website name.

  2. Create an app in App Engine https://console.cloud.google.com/appengine to your project
    Create an App

  3. To Deploy your website to the created app, download Google Cloud SDK from the link https://cloud.google.com/sdk/docs/quickstarts .

  4. Run Google Cloud SDK

  5. Initialize the Google cloud SDK with gcloud init command.
    Gcloud Init
    Next Step

  6. Create a website design for your startup in path_to_website_root_folder

  7. Point command prompt to the folder the website files exists
    cd ../../path_to_website_root_folder/

  8. Create app.yaml file and map website files in the website root folder. Follow the standards and code snippets in the link https://cloud.google.com/appengine/docs/standard/php/config/appref

  9. Deploy the app using command gcloud app deploy
    https://cloud.google.com/appengine/docs/standard/php/tools/uploadinganapp

  10. The files will be uploaded successfully and a subdomain will be generated on appspot domain. You can use that subdomain or connect your own domain to the project. https://console.cloud.google.com/appengine/settings/domains.

Top comments (4)

Collapse
 
rodiongork profile image
Rodion Gorkovenko • Edited

Hi Friend!

Google Appengine is not only for static websites. It allows creating dynamic sites in PHP/Python/Java. But for static it is probably not the best. And quite complicated. Also, if I remember correctly, nowadays deploys at Appengine require registering with credit card (even if no money are used).

For static content it is much better and easier to use Github (via Github Pages). This is completely free, easy and robust.

I even host static content of my dynamic websites here to decrease load on the server which creates dynamic content. I.e. use github as CDN.

Collapse
 
atooz profile image
Krishnakanth • Edited

Ha ha ..... Gud solution.
But could this be possible with Github pages if I want a contact form in the website forwarding details to mail. For that a backend is needed na ?

Collapse
 
rodiongork profile image
Rodion Gorkovenko

Yes, surely. As I mentioned, in this case optimal solution is to have static page with form in github, but form link should lead to google appengine backend (or heroku, or other free service).

The main idea is that AppEngine won't use caching by itself and if your site is under heavy load (not necessarily many users, but for example you put fat images here) your web site may have poor performance (especially due to vague AppEngine quotas).

For example one of web-sites I built CP-algorithms works this way - text content comes from AppEngine, but all javascript, css and images come from github pages. Both free.

I believe nowadays it is quite general approach to have static stuff separate from dynamic content...

Thread Thread
 
atooz profile image
Krishnakanth

Ok