How to deploy an Apache web app using Oracle Cloud

farisdurrani

Faris Durrani

Posted on October 30, 2024

How to deploy an Apache web app using Oracle Cloud

Let us create a basic public Apache web app using the Oracle Cloud Infrastructure (OCI)'s virtual cloud network and VM compute instance.

1. Create a VCN

Log in to Oracle Cloud at cloud.oracle.com.

Go to Virtual cloud networks in the Networking family.

Image description

Click on Start VCN Wizard to create a simple VCN with full Internet connectivity.

Image description

Click on Create VCN with Internet Connectivity

Image description

Then, click on the Start VCN Wizard.

Image description

Give the VCN a name.

Image description

Click on Next leaving everything else as default.

Image description

Click on Create on the next page and wait till the creation is complete.

Image description

2. Create a public VM instance

Go to the Instances page under the Compute family.

Image description

Click on Create instance

Image description

Ensure you select a public subnet from the VCN you just created:

Image description

Scrolling down in Add SSH keys, click on Save private key to download the SSH key you'll be using to log into the instance.

Then, click Create.

Image description

Once creation is done, copy the Public IP address of the compute instance.

Image description

3. SSH into instance and install Apache

Change directory to where you downloaded the SSH key, e.g., Downloads.

Change access mode of the SSH key using:

chmod 400 my-ssh-file.key
Enter fullscreen mode Exit fullscreen mode

to make it read-only for you for better security. Modify the name of the key to your key name.

Log into the VM using:

ssh -i ssh-key-2024-10-30.key opc@132.145.138.252
Enter fullscreen mode Exit fullscreen mode

changing your SSH key name and IP address to yours.

When prompted by the Terminal "Are you sure you want to continue...", answer yes.

Image description

Once in the VM, install Apache using:

sudo yum install httpd -y
sudo apachectl start
sudo systemctl enable httpd
sudo acpachectl configtest
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
sudo bash -c 'echo This is APP server 1 running on Oracle Cloud Infrastructure >> /var/www/html/index.html'
Enter fullscreen mode Exit fullscreen mode

Image description

When everything is done, run curl localhost:80 to ensure the web app is accessible locally inside the VM:

Image description

4. Allow public access to the VM web app

Going back to the Compute Instance page, select the subnet where it lives:

Image description

You'll arrive at the subnet details page. Select the security list used by the subnet.

Image description

You'll arrive at the security list details page. Click on Add Ingress Rules.

Image description

Add an ingress rule to allow incoming connections from everywhere (0.0.0.0/0) to port 80. Click Add Ingress Rules.

Image description

6. Validate web app

On your web browser, type in the IP address of your VM compute instance and validate you can see the following message:

Image description

Safe harbor statement
The information provided on this channel/article/story is solely intended for informational purposes and cannot be used as a part of any contractual agreement. The content does not guarantee the delivery of any material, code, or functionality, and should not be the sole basis for making purchasing decisions. The postings on this site are my own and do not necessarily reflect the views or work of Oracle or Mythics, LLC.

This work is licensed under a Creative Commons Attribution 4.0 International License.

💖 💪 🙅 🚩
farisdurrani
Faris Durrani

Posted on October 30, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related