DEV Community


Posted on

Using your Oracle Free Cloud to host your Wordpress website

One of the advantage of the Oracle Cloud Free Tier is that you can run up to 2 VMs on it.

This allows you to even have some "hosting" for some things like a web server or Rocket chat service

So, just to give you an example about what is possible, lets try installing WordPress in the quickest way possible

Start Creating a new VM and select your image Name before pressing the "Change Image" button

Change Image

For this example, we are going to use Centos7 image, which is one of the free images we have access to


Press "Show Shape, Network and Storage Options" and go to the bottom to make sure the system will ha a public IP

Show Shape

Public IP

Add your public SSH key and hit "Create"


Once the system is started, you should be able to see your "Public IP Address"

Public IP

Now, open a terminal and connect to the system using that IP:

P42@laptop:~ # ssh
The authenticity of host 'p42_vm (' can't be established.
ECDSA key fingerprint is SHA256:zWErGTOV9yEf.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'p42_vm,' (ECDSA) to the list of known hosts.
X11 forwarding request failed on channel 0
[root@p42-vm ~]# head -1 /etc/*rel*
==> /etc/centos-release <==
CentOS Linux release 7.7.1908 (Core)

==> /etc/centos-release-upstream <==
Derived from Red Hat Enterprise Linux 7.7 (Source)

==> /etc/os-release <==
NAME="CentOS Linux"

==> /etc/prelink.conf.d <==
head: error reading ¿/etc/prelink.conf.d¿: Is a directory

==> /etc/redhat-release <==
CentOS Linux release 7.7.1908 (Core)

==> /etc/system-release <==
CentOS Linux release 7.7.1908 (Core)

==> /etc/system-release-cpe <==
[root@p42-vm ~]#

First think we need is to get docker installed and started:

[root@p42-vm ~]# curl -fsSL -o
[root@p42-vm ~]# sh
# Executing docker install script, commit: 442e66405c304fa92af8aadaa1d9b31bf4b0ad94
+ sh -c 'yum install -y -q yum-utils'
Package yum-utils-1.1.31-52.el7.noarch already installed and latest version
+ sh -c 'yum-config-manager --add-repo'
Loaded plugins: fastestmirror, langpacks
adding repo from:
grabbing file to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 |  23 kB  00:00:00
 * base:
 * epel:
 * extras:
 * updates:
 | 3.6 kB  00:00:00
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'

 Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-19.03.8-3.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       :
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to
         for more information.
[root@p42-vm ~]#

[root@p42-vm ~]# systemctl enable docker
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/docker.service.
[root@p42-vm ~]# systemctl start docker
[root@p42-vm ~]#

Now that we have docker, we just need to get the dockers for the Wordpress components installed.
Create a directory for this project:

[root@p42-vm ~]# mkdir ~/wordpress && cd ~/wordpress
[root@p42-vm wordpress]#

Lets start with the Database for wordpress .
On this step we are installing mariadb engine, setting the root password to 'welcome1' and creating the DB 'wordpressdb'
(remember to use better passwords! :P)

[root@p42-vm wordpress]# docker run -e MYSQL_ROOT_PASSWORD=welcome1 -e 
MYSQL_DATABASE=wordpress --name wordpressdb -v 
"$PWD/database":/var/lib/mysql -d mariadb:latest
Unable to find image 'mariadb:latest' locally
latest: Pulling from library/mariadb
5bed26d33875: Pull complete
f11b29a9c730: Pull complete
930bda195c84: Pull complete
78bf9a5ad49e: Pull complete
e9e3c043ec68: Pull complete
141e45c6af4b: Pull complete
a26245908a82: Pull complete
40ccaf895c8a: Pull complete
2d665f60c94a: Pull complete
c7bcd9961bee: Pull complete
80f1ddb594ce: Pull complete
0647ec428f9f: Pull complete
9cb6e30e72ca: Pull complete
60890c0035d8: Pull complete
Digest: sha256:d0e2c681c41e91aba6e9c8c0a588eedd48291a70464e83c40da2e3de01998eef
Status: Downloaded newer image for mariadb:latest
[root@p42-vm wordpress]#

Create the local folder where the webserver will keep the files:

[root@p42-vm wordpress]# mkdir -p /var/www/html

And now lets get wordpress build installed.
Remember to use the DB name we set on previous step as well as the password.
We are also setting '/var/www/html' to keep the necessary webserver files
Additionally, we are setting docker to set the traffic coming to the host from port 80 to the container 80, since that is the default port the build has enabled:

[root@p42-vm wordpress]# docker run -e WORDPRESS_DB_PASSWORD=welcome1 
--name wordpress --link wordpressdb:mysql -p 80:80 -v 
"$PWD/html":/var/www/html -d wordpress
Unable to find image 'wordpress:latest' locally
latest: Pulling from library/wordpress
c499e6d256d6: Pull complete
3a635b94b3b9: Pull complete
cf28be682a33: Pull complete
b7118ab6e551: Pull complete
925f628a16b8: Pull complete
a77cff9973b5: Pull complete
9b4f44173a15: Pull complete
c9bd6c436ae3: Pull complete
399316af3112: Pull complete
3cea11f54c61: Pull complete
1ebb66998d8f: Pull complete
ac288a1a6e08: Pull complete
776d750cfd59: Pull complete
a997f5c2f033: Pull complete
a41091590f04: Pull complete
6b1397000eb2: Pull complete
7b387d8d3957: Pull complete
04673b988ee3: Pull complete
0e2da6305da6: Pull complete
f0224352bc00: Pull complete
d5e8b4e26a84: Pull complete
Digest: sha256:191d5caf4ef5b8c57721ade777820f3267654325f7902b2ccd377ceeba1c3fe2
Status: Downloaded newer image for wordpress:latest
[root@p42-vm wordpress]#

Remember to open port 80 of the host:

[root@p42-vm wordpress]# firewall-cmd --zone=public --permanent --add-port=80/tcp
[root@p42-vm wordpress]# firewall-cmd --reload
[root@p42-vm wordpress]#

[root@p42-vm ~]# docker ps
CONTAINER ID    IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
927e67368f23 wordpress           "docker-entrypoint.s¿"   7 minutes ago      Up 7 minutes>80/tcp   wordpress
d24bff4e7e94 mariadb:latest      "docker-entrypoint.s¿"   10 minutes ago     Up 10 minutes        3306/tcp             wordpressdb
[root@p42-vm ~]#

Now, go to the Oracle Cloud Gui and open the port 80 so we can connect to the system using that port.

From the Instance Details, click in "Virtual Cloud Network" → "Security Lists" → "Default Security list ...."



Here, we can now add new Rule for port 80, so system will allow connections




and Voila! free hosting ready :)

Wordpress Install

This is just an example of what you can do with your Oracle Cloud Free Subscription

Top comments (0)