Analytics Vidhya
Published in

Analytics Vidhya

Host WordPress for Free on Oracle Cloud

GIF showing four main components coming together to form WordPress

So you’ve just signed up for Oracle’s free tier cloud and you’re wondering what you can do with it. Or maybe you’ve come looking for a free solution to host a WordPress site (version 5.2). Either way this is something the Oracle cloud can do, and something it does well.

If you’d like a TLDR, give-me-my-WordPress-now version; I’ll quickly show you how to use a bash script I wrote to automate the setup process, and this will require minimal Linux understanding. Then I’ll break it all down for those of you curious about how it works.

Where’s My WordPress?!

Let’s dive right in! If you haven’t set up up your virtual machine on the cloud yet, check out the “Setting Up The VMs” section from this article, and take note of how to access the virtual machine via SSH.

Once you have remotely accessed your virtual machine, run the following line to download the bash script:

This will download ‘’ to your home directory. From here you have two options to run it; either use the ‘bash’ command, or make the script executable.

To use the bash command simply run the following, ensuring you are in your home directory:


Instead making the script executable is a two line process:

chmod +x ./

Both methods will result in WordPress being set up, so it’s up to you which you’d rather do.

Towards the end of the script you’ll be prompted for a few pieces of information:

  • a new password for the root user on the MySQL database
  • the name for your WordPress database
  • the name for a new user on the WordPress database
  • and a password for the new user

Once you’ve provided all of this, and the script has finished running, the virtual machine will be rebooted. Once it has finished rebooting (which could take about a minute), you can take the public IP address of the machine and navigate to it through a browser. There you’ll find the last few setup steps for your WordPress site; e.g. giving it a name, setting up an admin account, etc.

Image of admin page on WordPress

Bar using a third party service to set up a domain name for your new site, that’s it! Time to put some content into that site! Simple, no?

So What’s the Script Doing?

I’ll link you to my script, rather than dumping the entire thing here. If you’re looking at doing this manually, there are quite a number of lines of it that can be skipped. So I’ll only mention the relevant line numbers.

Starting at line 11 you will see a tuple ‘prerequisites’. These are (in order):

[0] the MySQL repository info location on the web

[1] the My SQL repository file

[2] the PHP for Oracle repository.

With the following commands replace the bracketed numbers with the above prerequisites. To make use of these [0] must be downloaded with the ‘wget [0]’ command, following this install [1] using ‘sudo yum localinstall -y [1]’. Finally use a normal install for [2]; ‘sudo yum install -y [2]’.

GIF of person typing

On line 12 is another tuple; ‘packages’. For each of these use ‘sudo yum install -y [tuple item]’ to install them all. The first item is the Apache web server package. This allows the virtual machine to provide a web page a browser can interpret and display. Also see line 22 which alters the firewall to allow inbound http traffic, i.e. other devices can request web pages from the virtual machine. The last item is the MySQL server that will run our database, and the items between these two are the various PHP packages necessary to host a WordPress site.

At time of writing the following versions of the above are installed: Apache Server version 2.4, MySQL version 8.0, PHP version 7.2. While WordPress version 5.2 is not the most recent version, the PHP version we have access to is a limiting factor. There is also a slight issue with MySQL version 8.0 and onwards that we need to work around.

GIF with 1s and 0s showing silhouette of a lock

In version 8.0 the default authentication encryption was changed, yet WordPress relies on using the older version of this. Thankfully, this is easily fixed by uncommenting one line in one of the MySQL files. This is addressed in line 23 of the script. Open ‘ /etc/my.cnf’ in your preferred text editor. There should be a block of commented text, ending with the line ‘# default-authentication-plugin=mysql_native_password’ (if you’re using nano as an editor you can use ctrl+w to search for this line). Simply uncomment this line and save the file.

Next, looking at lines 17–21 we will download the WordPress files, and place them in the Apache server’s directory. Using the wget on line 17, the files for version 5.2 of WordPress will be downloaded. The downloaded file must be unzipped, using the ‘tar -xzvf …’ command. The unzipped files are then moved to the default Apache directory, and the user ‘apache’ is given ownership of them.

To start the MySQL server, run line 24. You need to do this to continue the setup process. Now run ‘sudo grep ‘temporary password’ /var/log/mysqld.log’, to get the temporary password assigned to the root user. You will need this to make use of the MySQL server.

GIF showing a more secure WordPress

Running the following; ‘sudo mysql_secure_installation’, will greet you with a prompt for the temporary password. Once you provide it you will have to set a new password, followed by answering a series of y/n questions. These all involve removing testing tables/users, and revoking remote querying. Answering ‘y’ to each will provide you with a more secure setup.

Now we need to create a new database and associated user for WordPress. This can be done purely via the command line, or by logging in to mysql. I will be showing the latter here.

$ mysql -u root -p
[you will be prompted for the password now]
mysql> EXIT;

Above replace [DATABASE NAME], [USER NAME], and [PASSWORD] with your chosen names and password.

We’re almost done now. First rename ‘/var/www/html/wp-config-sample.php’ to ‘/var/www/html/wp-config.php’ using line 59. Next open up ‘/var/www/html/wp-config.php’ in your chosen text editor. We need to give WordPress some information so that it can access the database. We’re going to be doing some finding and replacing now. Find the following three lines:

define( ‘DB_NAME’, ‘database_name_here’ )
define( ‘DB_USER’, ‘username_here’ )
define( ‘DB_PASSWORD’, ‘password_here’ )

Replace ‘database_name_here’ with your choice for [DATABASE NAME] above, ‘username_here’ with [USER NAME], and ‘password_here’ with [PASSWORD]. Though be sure to leave the inverted commas in place.

Finally, using lines 69–72 restart the web server and MySQL server, and enable them to start when the virtual machine boots. Reboot the virtual machine now. Going to the public IP of the virtual machine in a web browser now will display the last few steps to get your WordPress site up and running!

I hope you found this useful, and enjoy filling your new websites with wonderful content!

If you’d like to get in contact, find me over on LinkedIn!

* All views are my own and not that of Oracle *




Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem

Recommended from Medium

How To Export .XLSX/ .CSV Files In R!

AWS API Proxy with AWS Lambda Function

A Guide To Flexbox

Cloud Adoption Patterns: Top Patterns for Moving to The Cloud

Protect your Room database with SQLCipher on Android

When It All Goes Wrong on Day One

What is Project Galaxy?

Heading banner for “What is Project Galaxy?”

Learning Journal | Nearsoft Academy | Week 12

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hugh Gallagher

Hugh Gallagher

Digital Advocate in Oracle Digital — Focusing on Database Security

More from Medium

GIT & GITHUB (Basics & Commands)

Installing MySQL on MacOS and making your First Schema

What is Back-End?

How to install an SSL certificate on Pound?