![](https://cdn.qwiklabs.com/assets/labs/start_lab-f45aca49782d4033c3ff688160387ac98c66941d.png)
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Deploy a web server VM instance
/ 30
Create a Cloud Storage bucket using the gcloud storage command line
/ 30
Create the Cloud SQL instance
/ 40
In this lab, you create a Cloud Storage bucket and place an image in it. You also configure an application running in Compute Engine to use a database managed by Cloud SQL. For this lab, you configure a web server with PHP, a web development environment that is the basis for popular blogging software. Outside this lab, you will use analogous techniques to configure these packages.
You also configure the web server to reference the image in the Cloud Storage bucket.
In this lab, you learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
In the Google Cloud console, on the Navigation menu (), click Compute Engine > VM instances.
Click Create Instance.
For Name, type bloghost
For Region and Zone, select the region and zone assigned by Qwiklabs.
For Machine type, accept the default.
In the left pane click OS and storage, if the Image shown is not Debian GNU/Linux 12 (bookworm), click Change and select version to Debian GNU/Linux 12 (bookworm).
Click Networking.
In Firewall, click Allow HTTP traffic.
In the left pane, click Advanced.
In Automation, copy and paste the following script as the value for Startup script:
Click Check my progress to verify the objective.
All Cloud Storage bucket names must be globally unique. To ensure that your bucket name is unique, these instructions will guide you to give your bucket the same name as your Google Cloud project ID, which is also globally unique.
Cloud Storage buckets can be associated with either a region or a multi-region location: US, EU, or ASIA. In this activity, you associate your bucket with the multi-region closest to the region and zone that Qwiklabs or your instructor assigned you to.
On the Google Cloud console, on the top right toolbar, click the Activate Cloud Shell . If a dialog box appears, click Continue.
For convenience, enter your chosen location into an environment variable called LOCATION. Enter one of these commands:
Or
Or
If prompted, click Authorize to continue.
Click Check my progress to verify the objective.
In the Google Cloud console, on the Navigation menu (), click SQL.
Click Create instance.
For Choose a database engine, select Choose MySQL.
For Choose a Cloud SQL edition, click Enterprise and then select Sandbox from the dropdown.
For Instance ID, type blog-db, and for Password type a password of your choice.
For Region, select the region assigned by Qwiklabs.
For Zonal availability, select Single zone.
Click Specify Zones, and then click Primary Zone. Select the zone assigned by Qwiklabs.
From the SQL instances details page, under Connect to this instance, copy the Public IP address for your SQL instance to a text editor for use later in this lab.
In the left pane, click Users, and then click Add User Account.
For User name, type blogdbuser
For Password, type a password of your choice. Make a note of it.
Click Add to add the user account in the database.
In the left pane, click Connections, and then click Networking tab.
Click Add a Network.
For Name, type web front end
For Network, type the external IP address of your bloghost VM instance, followed by /32
The result will look like this:
Click Done to finish defining the authorized network.
Click Save to save the configuration change.
Click Check my progress to verify the objective.
On the Navigation menu (), click Compute Engine > VM instances.
In the VM instances list, click SSH in the row for your VM instance bloghost.
In your ssh session on bloghost, change your working directory to the document root of the web server:
Press Ctrl+O, and then press Enter to save your edited file.
Press Ctrl+X to exit the nano text editor.
Restart the web server:
When you load the page, you will see that its content includes an error message beginning with the words:
In the nano text editor, replace CLOUDSQLIP
with the Cloud SQL instance (blog-db) Public IP address that you noted above. Leave the quotation marks around the value in place.
In the nano text editor, replace DBPASSWORD
with the Cloud SQL database password that you defined above. Leave the quotation marks around the value in place.
Press Ctrl+O, and then press Enter to save your edited file.
Press Ctrl+X to exit the nano text editor.
Restart the web server:
In the Google Cloud console, click Cloud Storage > Buckets.
Click the bucket that is named after your Google Cloud project.
In this bucket, there is an object called my-excellent-blog.png. Copy the URL behind the link icon that appears in that object's Public access column, or behind the words "Public link" if shown.
Return to your ssh session on your bloghost VM instance.
Enter this command to set your working directory to the document root of the web server:
Use the arrow keys to move the cursor to the line that contains the h1 element. Press Enter to open up a new, blank screen line, and then paste the URL you copied earlier into the line.
Paste this HTML markup immediately before the URL:
The resulting line will look like this:
The effect of these steps is to place the line containing <img src='...'>
immediately before the line containing <h1>...</h1>
Press Ctrl+O, and then press Enter to save your edited file.
Press Ctrl+X to exit the nano text editor.
Restart the web server:
In this lab, you configured a Cloud SQL instance and connected an application in a Compute Engine instance to it. You also worked with a Cloud Storage bucket.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Read the Google Cloud Platform documentation on Cloud SQL.
Read the Google Cloud Platform documentation on Cloud Storage.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one