Note:

Create an Oracle Cloud Infrastructure Compute Instance Webserver using an OCI Database as the main Backend

Introduction

In this tutorial, we will create a two-tier application consisting of an Oracle Cloud Infrastructure (OCI) Compute instance that will act as a webserver and an OCI Database service (MySQL). We have created a sample website and database and this website will retrieve the data from the OCI Database table.

image

image

Objectives

Task 1: Create a new Virtual Cloud Network (VCN)

We already have a VCN created but if you still need to create a new VCN, follow the tutorial: Create a New VCN with IPv6 Enabled.

Click the hamburger menu from the upper left corner. Click Virtual Cloud Networking to verify if the virtual cloud network exists.

image

For this tutorial, we already have a VCN.

image

Task 2: Create a new Public Subnet and Private Subnet

We already have a public and private subnet created but if you still need to create new subnets, follow the tutorials: Create a new Public Subnet with IPv6 Enabled and Create a Private Subnet inside the VCN.

Inside this VCN, we have a public and private subnet available. We will connect OCI Compute instance to the public subnet and OCI Database to the private subnet.

To review the available OCI Compute instances, click the hamburger menu from the upper left corner.

image

Task 3: Create a new OCI Compute Instance

We already have an OCI Compute instance created but if you still need to create a new OCI Compute instance, follow the tutorial: Task 3: Create a New Instance with IPv6 Enabled.

Click Instances to review the OCI Compute instances.

image

The public facing compute instance is up and running.

image

Task 4: Create a new MySQL Database engine

Review the private IP address 10.0.2.247 that will be used later to configure and access the MySQL Database.

image

Task 5: Create a new Database with Sample Data (1 Table with 2 Records)

Now, we have a sample database with some sample tables and sample data running inside OCI using the OCI Database MySQL service. The next task is to retrieve this data using a PHP website.

Task 6: Install and Configure an NGINX Webserver with PHP

We already have a compute instance with NGNIX and PHP created but if you still need to create a new instance with NGNIX and PHP, follow the tutorial: Task 6: Install a Webserver on Instance.

In the previous NGINX with PHP setup, we did not install any PHP MySQL modules. A quick check on PHP Info page will confirm this.

image

Task 7: Create a Website that Connects to the Database and Displays the Records on a Webpage

When we connect to the website /testocidb/index.php, we are able to access the website successfully and most importantly we will see the data stored in the database.

image

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.