Using Oracle Cloud, Part 2: An 'Always Free' Web Server Platform

Tom Fenton details the web server work he did in his experiment to use an "Always Free" Ubuntu 18.04 VM on Oracle Cloud to host a small web site.

In a previous article, I detailed how it took less than 10 minutes to sign up for, create and use an "Always Free" Ubuntu 18.04 virtual machine (VM) on Oracle Cloud. Yes, the free VM wasn't that large (1 vCPU, and 4GB RAM), but I figured it would allow for the creation of a small web site -- a good test of Oracle Cloud because the web site on the VM would need to be opened up to allow access to the outside world. In this article, I will discuss what web server I chose to use, how I installed it and how well it works.

Why Apache
The No. 1 priority for my web server was simplicity; I just wanted a basic web site that displays a "Hello World" message. I wanted to verify that a VM on Oracle Cloud would support an application like a web server and that it would allow connectivity to the outside world.

Apache is a free open source web server that is, according to Netcraft, the most widely used web server on the net. In the past, when I have installed it, I have found that it just works. It is stand-alone and doesn't require any additional components, but due to its popularity, it is highly extensible and has plenty of articles, advice and (most importantly) help freely available for it.

Installing Apache
Below are the steps I took to install Apache on my Oracle-Cloud-based VM. After logging in to my VM using SSH as the user ubuntu, I entered the following commands:

  1. sudo bash (this made me the root user)
  2. apt install apache2 (this downloaded and installed Apache)

Verifying that Apache Is Installed
To verify what version of Apache was installed and that it was operational, I entered the following commands:

  1. apache2 -v. # (this displays the version (-v) of Apache that was installed)
    [Click on image for larger view.]
  2. ps -aux | grep apache2. # (this verifies that Apache2 is running)
    [Click on image for larger view.]
  3. netstat -anp | grep apache. # (this verified for me that the Apache2 process was listening in on port 80)
    [Click on image for larger view.]
  4. apt install lynx. # (this installs Lynx, a text-based web browser)
  5. lynx localhost. # (this starts the Lynx web browser and connects to the local host)
    [Click on image for larger view.]
  6. I then went to my laptop and tried to access the web server using Chrome. This timed out and failed. I suspected that Oracle Cloud was blocking the port Apache uses (80).
    [Click on image for larger view.]

Opening the Oracle Cloud Port for Apache
By default, Oracle Cloud blocks all ports to the VMs that it is hosting except the port used by SSH. To allow external connections to your VMs, you will need to open the ports to it from the Oracle Cloud portal. After I logged into the portal, I did the following:

  1. I selected Dashboard, expanded Compute and clicked Instances.
    [Click on image for larger view.]
  2. I selected my Instance.
  3. From the Instance Information tab, I selected Subnet.
    [Click on image for larger view.]
  4. I selected the security list that was displayed.
    [Click on image for larger view.]
  5. I clicked Add Ingress Rule and opened up port 80.
    [Click on image for larger view.]
  6. I verified that the new ingress rule was shown.
    [Click on image for larger view.]
  7. When I tried again to access the site, it failed.

Opening the Ubuntu Port for Apache
To allow external connections to my VMs, I would also need to open the port to it on Ubuntu's firewall. From the ubuntu shell, I did the following:

  1. I verified that the UFW firewall was not running by entering ufw status
    [Click on image for larger view.]
  2. .
  3. Ubuntu 18.04 also has a kernel-based IP filter, iptables. I listed what ports were allowed by entering iptables --list. This showed me that it did not have a rule to open port 80. To open port 80 and restart the Apache server, I entered the following:

    iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT
    netfilter-persistent save
    systemctl restart apache2
          

After I opened the port, I went back to my laptop and found that I was able to connect to the web server.

[Click on image for larger view.]

Summary
I was able to install and access an Apache web server that was running on an Ubuntu VM that was being hosted on Oracle Cloud. It took me a little time to figure out how to open the firewall on Oracle Cloud and then on the VM, but after I figured out what needed to be opened and how to open it, the process was quick.

This Oracle Cloud "Always Free" instance would not be able to handle a big or complicated web site, but that is not what this article is about nor or is it the reason why Oracle is offering this free service. Oracle is offering this service to allow people to get their hands dirty with their cloud services, and that is what I intended to highlight in this article. Although VM creation is just a small aspect of Oracle's cloud offering, I was impressed by how easy it was to sign up, create and manage a VM. Hopefully Oracle continues this ease of use with their other cloud services.

See "Using Oracle Cloud, Part 3: Checking Network Performance on VMs."

About the Author

Tom Fenton has a wealth of hands-on IT experience gained over the past 25 years in a variety of technologies, with the past 15 years focusing on virtualization and storage. He currently works as a Technical Marketing Manager for ControlUp. He previously worked at VMware as a Senior Course Developer, Solutions Engineer, and in the Competitive Marketing group. He has also worked as a Senior Validation Engineer with The Taneja Group, where he headed the Validation Service Lab and was instrumental in starting up its vSphere Virtual Volumes practice. He's on Twitter @vDoppler.

Featured