If you reading this then you must be wondering how to install WordPress for free and trying to find a solution to host it on a lifetime free hosting server.
In this post, I’ll explain to you how to install WordPress on Oracle Cloud easily without having any knowledge of Linux or WordPress.
It is possible to get a free virtual server on various Cloud providers, but some of them just offer you an option of free resources for one year or less and that’s the major limitation. What we want here is a server that is completely free forever (“always free”) so you are in no need to migrate between them. That’s why I prefer Oracle Cloud here, which provides two virtual servers and other always free services. Of course, I cannot guarantee that Oracle may change this in the future so please check on their website for pricing.
How to Start
You’ll need an Oracle Cloud Infrastructure Free Tier account to set up an Ubuntu 20.04 virtual machine so before you begin you should sign up for Oracle Cloud Infrastructure Free Tier.
Network Configuration
At the beginning create your Virtual Cloud Network (VCN) in order to connect your Server to the internet. On the main page choose Set up a network with a wizard.
In the VCN Wizard select VCN with Internet Connectivity and then start VCN Wizard.
In the configuration fill in your VCN Name (WordPress Internet e.g.). Leave Compartment with its default value of your tenancy.
In the Configure VCN and Subnets section, keep the already configured default values:
- VCN CIDR BLOCK: 10.0.0.0/16
- PUBLIC SUBNET CIDR BLOCK: 10.0.0.0/24
- PRIVATE SUBNET CIDR BLOCK: 10.0.1.0/24
For DNS RESOLUTION uncheck USE DNS HOSTNAMES IN THIS VCN.
Click Next and in configuration dialog click Create to create your VCN.
Click View Virtual Cloud Network to view your new VCN.
In your new VCN, you need to add a security rule to allow HTTP/S connections on port 80/443. Click your Public subnet link.
The public subnet information is displayed with the Security Lists at the bottom of the page. There should be a link to the Default Security List for your VCN.
Click on the Default Security List link and choose Add Ingress Rules.
Fill in the ingress rule as follows and once all the data is entered, click Add Ingress Rules:
Once you click Add Ingress Rule, HTTP and HTTPS connections are allowed. Your VCN will make your VM available from the internet.
Create SSH Keys
In order to connect to your VM, you’ll need to create SSH encryption keys. To create your SSH keys on Windows just search in your favorite browser how to do this, because there are various options to do this (PuTTy, WSL, Git). I’ll explain here how to do this on macOS or Linux.
Open a terminal window in the directory where you want to store your keys and issue the following OpenSSH command:
ssh-keygen -t rsa -N "" -b 2048 -C <your-ssh-key-name> -f <your-ssh-key-name>
The command is going to generate some random text art used to generate the keys and when complete, you will have two files:
- The private key file:
<your-ssh-key-name>
- The public key file:
<your-ssh-key-name>.pub
You just have generated the required encryption keys and you use these files to connect to your VM.
Install Ubuntu VM
From the Oracle Cloud Infrastructure main menu, select Compute, then Instances and then click Create Instance.
Fill in the fields for the Create Compute Instance dialog with the following data:
- Name of your VM: <name-for-the-VM>
- Image or Operating System (Click Change Image): Canonical Ubuntu 20.04
- Availability Domain: <Select-an-always-free-eligible-domain>
- Instance Shape: VM.Standard.E2.1.Micro: Virtual Machine, 1 core OCPU, 1 GB Memory, 0.48 Gbps network bandwidthName of your Instance: <name-for-the-instance>
and then in order to add SSH Keys just paste the public key file (.pub) you created in the previous step.
Click Create to create the instance. Be aware that provisioning the system may take several minutes.
Increase Linux OS Virtual Memory
When you create your free instance in Oracle Cloud it comes with 1 GB memory only, so you should try to increase the server virtual memory without having to pay for additional memory. You can simply specify space on the hard disk which will be used as physical memory. Linux swap files allow a system to harness more memory than was originally physically available (RAM).
To check your available memory and current swap space use following command:
free -m
Now create a swap file and allocate space of the size decided upon earlier with the command. Here I am using 1 GB but you can add more. 1024 is the size of the swap file in megabytes and the full name of the swap file is /mnt/swap.0.
sudo dd if=/dev/zero of=/mnt/swap.0 bs=1024 count=1048576
sudo mkswap /mnt/swap.0
After marking the file, enable the swap file, allowing your system to start utilizing it:
sudo swapon /mnt/swap.0
Verify that the swap is available:
sudo swapon --show
Changes you made have enabled the swap file for the current session. After the reboot, the server will not retain the swap settings automatically. You can change this by adding the swap file to your /etc/fstab
file.
Back up the /etc/fstab
file in case anything goes wrong:
sudo cp /etc/fstab /etc/fstab.bak
Add the swap file information to the end of your /etc/fstab
file with the following command:
echo '/mnt/swap.0 swap swap defaults 0 0' | sudo tee -a /etc/fstab
Check swap size for memory:
free -m
And there you go, enough memory for running a web server and WordPress. You can additionally adjust the swappiness property and the cache pressure setting in order to get your system to run even smoother.