Running a Web Server on Oracle Compute Instance

Every website sits on a computer which is basically as a Web server. A web server processes requests via HTTP(s) and other related protocols.

There are several web servers out there, but i shall focus on installing Apache HTTP server on Oracle Linux and Ubuntu operating systems running on Oracle compute instances.

Prerequisites:

  • Oracle Cloud Infrastructure compute instance
  • SSH Client ie. PuTTY
  1. Installing Apache HTTP on Oracle Linux.
Install Apache http
sudo yum install httpd -y

Start Apache server and configure it to start at system reboots

sudo apachectl start
sudo systemctl enable httpd

Check if the Apache configuration syntax is correct, run:

sudo apachectl configtest

Now create firewall rule to access all ports that HTTP listens to.

sudo firewall-cmd --permanent --zone=public --add-service=http

sudo firewall-cmd --reload

Find the web root directory for your web server and add your web files. ( Found at the “/var/www/html” folder)

One more thing!

Open port 80 in the security lists of your compute instance. 

Navigate to your compute instance and select your VCN.

Click on security lists on the left bar under resources and select the default security list for your VCN.

Add an ingress rule for port 80, edit the values as shown on the image below.

Source Type: CIDR
Source CIDR: 0.0.0.0/0
IP Protocol: TCP
Source Port Range: All
Destination Port Range: 80

Click on Save Security List Rules at the bottom.

ingress

Almost done now…

Create an Egress rule to allow traffic for all ports.

egress

All done!

To test open your  favorite web browser and navigate to the public IP address of the Linux VM.

http://Public-IPAddress/your-web-file.index.html

webpage

I have configured DNS to resolve to my public IP address on my Oracle compute instance. I will show you how to do that on the next post 🙂

It works!

2. Installing Apache HTTP server on Ubuntu

The whole process of configuring the compute instance security lists is the same as above, only the commands for installing Apache on Ubuntu change a little bit.

Log in to your compute instance running on Ubuntu using SSH.

Search the Apache package:

apt-cache search apache

Install the Apache2 package using the root privileges.

sudo apt-get install apache2

Where is the Apache HTTP server installed?

To find out,  run the find command:

sudo find / -name apache2

find

Navigate to your web root folder and add your web files. (Found at /var/www/html)

Test out your web browser using your favorite browser.

http://Public-IPAddress/your-web-file.index.html

Final Thoughts:

Apache HTTP server is an open source cross platform web server software which can can also act as an application server. There are several other web servers out there ie. Nginx, IIS etc.

References:

Thank you and Happy coding! If you liked it, share it!

This blog reflects  my own thoughts and doesn’t reflect the thoughts of my employer.