How to Upload Website to Google Cloud
Hosting a static website on Google Cloud using Google Cloud Storage
Get Cooking in Cloud
Introduction
In this mini series we are covering, how to create websites on Google Deject. This is the 2nd commodity in the serial.
- Hosting spider web apps on Google Cloud: An Overview
- Hosting a spider web app on Google Cloud using Google Cloud Storage (This web log)
- Hosting a web app on Google Cloud using Deject Run
- Hosting a web app on Google Cloud using Google Compute Engine
- Scaling web app on Google Compute Engine
- Case Report
Permit's say you're a small visitor looking to prepare upwards a basic web presence. You lot don't expect a lot of traffic, and don't want to pay a lot to become upwardly and online. And so, read on to find how to start pocket-size past deploying a static website.
What you'll learn
- Create static website on Google Cloud
- Bespeak your domain to GCS
- Create bucket, upload and share the files using admission control
- Ready index folio suffix and error page
- Test the website
Prerequisites
- Read the first commodity that covers loftier level concepts virtually setting up websites on Google Deject.
Cheque out the video
What is a static website?
Static websites are a good option for sites like blogs — where the page rarely changes afterward information technology has been published, or where there isn't any dynamically-generated content. Static web pages tin comprise client-side technologies such as HTML, CSS, and JavaScript. They cannot contain dynamic content such every bit server-side scripts, like PHP.
How to create static websites on Google Cloud
Earlier we brainstorm, we need to make sure we are properly fix up in Google Deject Console. Ensure the following:
- You take a GCP project created
- A Billing account is prepare
- You lot have a domain that y'all own or manage (this should exist a Peak level domain). To verify that you lot manage the domain, check here.
At present that we've covered the logistics, at that place are four steps to set up a static web app.
Step 1 : Indicate your domain to GCS
First stride is to connect your domain to cloud storage. To do that, create a CNAME record that points to c.storage.googleapis.com. Your domain registration service can help with this.
www.example.com CNAME c.storage.googleapis.com.
Step two : Create the bucket that is linked to your domain
2nd step is to create a Google deject storage bucket. To exercise this, browse to the google cloud panel, click on cloud storage, and click create bucket. Make certain the bucket proper name matches the CNAME created for your domain. In this case, the storage bucket should be named www.instance.com
Footstep 3 : Upload and share your site'southward files
Tertiary step is to upload the files yous desire your website to serve. We can do this in one of two means.
Commencement, by directly uploading files using the google cloud console.
Second, is using gsutil command line, which is not bad for when you have an existing website.
gsutil rsync -R local-dir gs://www.example.com
Access Control:
Once the files are uploaded, nosotros need to make sure they are properly shared for access. You can either brand all files in your bucket publicly accessible, or you can prepare individual objects to exist accessible through your website. Mostly, making all files in your saucepan attainable is easier and faster.
At this point, nosotros essentially have a functioning static website but it is recommend to assign an index folio suffix and a custom mistake page to guide the users better.
Index folio suffix and Custom fault page:
This helps in scenarios when say you have no file named apple tree in your bucket www.case.com. In this situation, if a user requests the URL http://www.example.com/apple, Deject Storage attempts to serve the file world wide web.example.com/apple/index.html. If that file likewise doesn't be, Deject Storage returns an fault page with 404 response.
You can learn more about setting this up here.
Step 4 : Test the website
The last step is to test our static website. Verify that content is served from the bucket by requesting the domain proper name in a browser.
Serving HTTPs content on GCS
One important thing to note is that GCS ONLY supports HTTP. In order to serve HTTPS, and get all that security goodness, we demand to either using directly URIs using a CNAME redirect, or migrate to using a load balancer as a forepart-finish every bit shown in the motion-picture show.
Conclusion
In this article we learned how to start small and deployed a static web awarding on Google Cloud platform. We used Google cloud storage to host the static content and pointed the Domain name to the storage bucket.
Next steps
- Follow this weblog series on Google Deject Platform Medium.
- Follow Become Cooking in Cloud video series and subscribe to Google cloud platform YouTube aqueduct
- Want more than stories? Bank check my Medium, follow me on twitter.
- Enjoy the ride with the states though this series and learn more than about Google Cloud :)
Source: https://medium.com/google-cloud/hosting-a-static-website-on-google-cloud-using-google-cloud-storage-ddebcdcc8d5b
0 Response to "How to Upload Website to Google Cloud"
แสดงความคิดเห็น