
Lab Overview:
In this lab, we will create a Compute Engine using a WordPress Startup script. There is another way where you can use WordPress Image to launch the instance but that could be an expensive approach. We have provided the startup script and way to connect to the Database.
Lab Details:
- This lab walks you through Installing WordPress on Compute engine using Startup Script.
- Make sure, you have completed the Compute Engine lab and Cloud SQL lab. This lab will directly jump on to building WordPress, and not get into the detail of Compute Engine. If you have not completed the previous labs, we recommend you complete the previous labs first.
- In this lab, we will use a Startup script to install WordPress, and then connect WordPress with Cloud SQL.
Lab Tasks:
- Login into GCP Console.
- Creating a Firewall Rule.
- Creating a Compute Engine using a Startup script.
- Creating a Cloud SQL Instance.
- Create a Cloud SQL Database.
- Configuring WordPress to connect with Cloud SQL
- Testing the WordPress Site
Creating a Firewall Rule:
- Click on the hamburger icon on the top left corner
- Select VPC network.
- Click on Firewall.
- Click on Create firewall rule

5. Enter the firewall rule name as http-allow.
6. Choose the network as default.
7. Enter priority number as 1000.
8. Choose direction as Ingress as we are allowing all incoming HTTP traffic.
9. Choose Allow as we want to allow the incoming traffic.

10. Choose target as all Instances in the network. Same rule will apply for all the instances in the network
11. Enter the Source IP range as 0.0.0.0/0 which means Internet.
12. Enter the port as 80 and check TCP as we are allowing HTTP traffic, HTTP port is 80.

13. Click on create to create the firewall rule.

Creating a Compute Engine:
- Click on the hamburger icon on the top left corner
- Click on Compute Engine.
- Click on Create.
- Enter the name as wordpress-instance. Do not enter any other name, It is required to validate the lab.
- Keep the region to us-central1 and Zone as us-central1-a.
- Choose series as N1
- Choose the machine type n1-standard-1.

8. Click on the down arrow to expand more options.
9. Enter the Startup script provided in the Supporting Document name WordPress Script.

10. Click on Create.
11. Now, your instance is up and running.
12. Make a note of your External IP.[34.69.23.79].

Creating a Cloud SQL Instance:
- Click on the hamburger icon on the top left corner.
- Click on SQL under the Database section

3. Click on Create Instance to create your database instance.
4. Choose your database engine as MySQL.

5. Enter instance id as wordpress-db-<your-title>. For e.g. If your title is dev then enter instance id as wordpress-db-dev.
6. Set any password for your root user and keep a note of it, It is required at a later stage.
7. Choose database version as MySQL 5.7

8. Select region as us-central1 and Any zone. Please note, User Interface might differ for you. You should choose an us-central1 region.

9. Click on show configuration options.

10. Select the machine type as lightweight and has 1 Core with 3.75 GB of memory.
11. Click on the dropdown to change the machine type as Lightweight and select 1 vCPU, 3.75 GB.

12. Change the Storage type by clicking the down arrow on the right side.
13. You can choose any storage type. In our case, we are choosing SSD and storage capacity as 10 GB.

14. Click on the down arrow in the Connectivity tab. Make sure Public IP is enabled.

15. Click on Add network to allow your WordPress instance to connect with your DB Instance.
16. Enter the name as wordpress-network.
17. Enter the Network IP as the External IP of your Compute Engine which you noted earlier.

18. Click on Done.
19. Click on Create Instance to finally create your DB Instance.

20. Make a note of the Public IP of your DB Instance. You can find it in the Cloud SQL Instance.[35.226.21.18].
Creating a Google Cloud SQL Database:
- Once you create DB Instance, click on databases.

2. Click on Create Database.
3. Enter the database name as wp_db. Do not enter any other name.
4. Keep the character set as utf8 and Collation as Default Collation.

5. Click on create.

Configuring WordPress to connect with Cloud SQL:
- Click on the hamburger icon on the top left corner.
- Now Click on Compute Engine > VM instances.
- Copy the External IP of your Compute Engine and hit the URL.[34.69.23.79].


4. You will see the configuration page for your WordPress. Choose the language and continue.
5. Read the instruction and click on Let’s go!.

6. Enter the database name which you created in the earlier steps.
7. Enter the username as root.
8. Enter the password which you choose while creating the DB Instance.
9. Enter the Public IP of your DB Instance which you noted earlier in the Database Host.
10. Enter the table prefix as wp_
11. Click Submit.

12. Done, You are now connected with your Database. Now, click on Run the installation to create a WordPress website.

13. Choose the Site title as Hello Whizlabs.
14. Enter any username. It is required to login to the wordpress admin panel. In our case we have chosen root.
15. Enter any Password. It is required to login to the wordpress admin panel.
16. Enter your email address.

17. Click on Install WordPress.

18. Enter the External IP of your Compute Engine in the URL.
19. You can view the Hello world! post from your WordPress website.

Completion and Conclusion:
- In this lab, you have created a Compute Engine with a Startup script to install WordPress.
- You have created a SQL Instance and Database.
- You have configured WordPress to connect with Cloud SQL Database.
Happy Learning !!!

I don’t think the title of your enticle matches the content lol. Just kidding, mainly because I had some doubts after reading the enticle. https://www.binance.com/en/register?ref=P9L9FQKY
I am a student of BAK College. The recent paper competition gave me a lot of headaches, and I checked a lot of information. Finally, after reading your article, it suddenly dawned on me that I can still have such an idea. grateful. But I still have some questions, hope you can help me.
Your article made me suddenly realize that I am writing a thesis on gate.io. After reading your article, I have a different way of thinking, thank you. However, I still have some doubts, can you help me? Thanks.