CLOUD TUTORIALS

WordPress website on Oracle Cloud Free Tier

Are you planning to start a WordPress website for Free, without spending a penny? If so, then you should take a look at Oracle.

Why Choose Oracle Cloud?

There are many famous cloud providers that offer Free Tier (like AWS, G Cloud, etc.), then why should you choose Oracle Cloud?

wordpress on oracle cloud

AWS & Google Cloud free Tier of their services, but they limits you on Network Bandwith.

Aws provides you free tier for 12 months with only 1GB Network Bandwidth, anything past 1GB will be billed as per their rates.

Google Cloud allows you to use Free tier forever, but the CPU provided in Free tier is not large enough to handle moderate traffic, and it also has low Network Bandwidth limit.

But Oracle Cloud on the other hand, offers you Forever Free Tier with 2 VMs (1GB memory each) 10TB Network Bandwidth + 100GB Block Storage + 10Gb Object Storage. This configuration is more than enough to run a website with moderate traffic for Free Forever.

How to install WordPress on Oracle Cloud Free Tier?

Setting up WordPress on self-managed VPS can be quite complex. So In this article, I’ll show you how to install and host WordPress on Oracle Cloud Forever Free tier.

Creating a VM:

First, create a VM by going to your Oracle Cloud dashboard and clicking “Create a VM instance“.

On the Next page, Give a name to your instance, Select Ubuntu image from the list of available images. Click on show Shape, Network and Storage options, and make sure you have selected “Always Free Eligible” items.

Leave all the settings to default, scroll down and Generate a “SSH key pair”. This SSH key will be used to connect to your instance, so keep it safe.

Finally, click on create instance.

Once the instance has been created, open Terminal or command line on your PC and type ssh opc@youripaddress. Replace youripaddress with your Oracle Instance’s ip address.

Next part is Installing WordPress on your instance.

There are 2 ways to install WordPress on your instance: The Easy way & The Complex way. If you’re just looking to get your WordPress up and running as soon as possible, go with the easy way, If you are doing this to learn something new then go with the complex/manual way.

First: The Easy way

Installing WordPress via EasyEngine:

In this method we’ll Install WordPress using EasyEngine, EasyEngine is a terminal-based management tool that installs all necessary packages required by WordPress automatically in just a single command.

To install EasyEngine, SSH into your instance and enter the following command:

wget -qO ee https://rt.cx/ee4 && sudo bash ee

It’ll take few minutes to complete the installation process.

Next, you need to point your domain to Oracle Cloud’s instance, you can do that by creating an A record in your Domain Registrar’s DNS setting.

AHostTTL
@<your instance’s IP address here>auto

Once your Domain is pointed to your instance, enter the below command to install WordPress along with Free Letsencrypt SSL.

sudo ee site create yourdomain.com --wp --letsencrypt

If you don’t want Letsencrypt SSL, then remove the –letsencrypt part.

Now, it will again take few minutes to install all necessary packages, and present you with your WP Login credentials.

And, That’s it. Your WordPress website is now created, you can visit yourdomain.com/wp-admin to log into your dashboard.

You can use the command sudo ee site create yourdomain.com --wp --letsencrypt multiple times to create multiple WordPress websites on the same instance.

Second: The Complex way

If you want to do all the things manually (like installing Php, MySQL, setting up users), then follow this method.

After creating your instance, the next step is to install LAMP stack on it.

SSH into your instance and Enter the below 2 commands (one by one) in the terminal window – to install tasksel: (Press “Enter” after each command)

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install tasksel

Use tasksel to install the LAMP server:

sudo tasksel install lamp-server

This will install Apache, MySQL, & Php on your instance (the 3 things that are required by WordPress to run).

install lamp server on ubuntu command line

Next, you need to create a database and users for WordPress.

This is the table that we need to create:

DomainDatabaseUsernamePassword
example_domain.comexampledb_wordpressexample_wpuserdb_password

If you want to create multiple WordPress websites, then you need to create the above table for each instance.

To create the table, log into MySQL as root user buy entering the following command:

sudo mysql -u root

Create the WordPress database:

CREATE DATABASE exampledb_wordpress;

The exampledb_wordpress is the name of your database, you can change it to whatever you like.

Create Database user and password:

CREATE USER 'example_wpuser' IDENTIFIED BY 'db_password';

Change example_wpuser & db_password with your desired username and password. (Remember, that these are the username & password of your Database, not WordPress)

Now you need to grant user privileges to the newly created user and exit MySQL.

GRANT ALL PRIVILEGES ON exampledb_wordpress.* TO 'example_wpuser';

quit

Create directories to hold WordPress files.

WordPress source files directory:

sudo mkdir -p /var/www/html/example_domain.com/public_html

WordPress tarball files directory:

sudo mkdir /var/www/html/src/

Download and store WordPress file to the above src directory:

cd /var/www/html/src/ 

sudo wget http://wordpress.org/latest.tar.gz

Extract the downloaded Tarball file:

sudo tar -zxvf latest.tar.gz

Copy WordPress files to publc_html:

sudo cp -R /var/www/html/src/wordpress/* /var/www/html/example_domain.com/public_html/

Give Apache root permissions:

sudo chown -R www-data:www-data /var/www/html/example_domain.com/

Configure Apache Virtual Hosts:

This method is required in case you want to host multiple WordPress websites in future. So that each domain pointing to your instance serves content from its own specified folder.

Create a file called example_domain.conf paste the below text in it:

<VirtualHost *:80>
    # The primary domain for this host
    ServerName example_domain.com
    # Optionally have other subdomains also managed by this Virtual Host
    ServerAlias example_domain.com *.example_domain.com
    DocumentRoot /var/www/html/example_domain.com/public_html
    <Directory /var/www/html/example_domain.com/public_html>
        Require all granted
        # Allow local .htaccess to override Apache configuration settings
        AllowOverride all
    </Directory>
    # Enable RewriteEngine
    RewriteEngine on
    RewriteOptions inherit

    # Block .svn, .git
    RewriteRule \.(svn|git)(/)?$ - [F]

    # Catchall redirect to www.example_domain.com
    RewriteCond %{HTTP_HOST}   !^www.example_domain\.com [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/(.*)         https://www.example_domain.com/$1 [L,R]

    # Recommended: XSS protection
    <IfModule mod_headers.c>
        Header set X-XSS-Protection "1; mode=block"
        Header always append X-Frame-Options SAMEORIGIN
    </IfModule>
</VirtualHost>

    

and upload it to /etc/apache2/sites-available/ directory. You can do this by using Filezilla.

Replace all appearance of example_domain.com with your domain.

Create the symlink:

sudo a2ensite example_domain.conf

Now, check if the rewrite module is enabled by using the below command:

sudo apache2ctl -M

If you don’t see rewrite module in the list, enable it by the below command (If it is already present, skip this step)

sudo a2enmod rewrite

Finally Reload Apache:

sudo systemctl reload apache2

Complete WordPress Installation

If your domain is already pointed to your instance, then you can just type your domain in the browser to finish WordPress installation. Otherwise, visit: http://yourinstanceIPaddress/example_domain.com/public_html or http://yourinstanceIPaddress/wp-admin in your browser.

You should now see the WordPress setup wizard.

wordpress setup wizard

So this was the manual way of installing WordPress on Oracle Cloud, I’ll recommend that you use the First method because this method is really complex and you can run into many issues.

Leave a Comment