You’ve probably heard about the 12 months free VM from Amazon AWS or the free micro VM, but did you know you can get up to four servers from Oracle Cloud, and it’s free forever?
Oracle Cloud is probably offering the most generous always free tier of all Cloud IaaS providers, unlike Google Cloud, where the free instances are only limited in the US. This is what you can get from Oracle Cloud Always Free Tier every month:
- 3,000 OCPU Hours + 18,000GB Hours for ARM-based VM
- 2x AMD VM with 1 shared CPU and 1GB RAM
- 200GB Block Volume
- 10TB Outbound Data Transfer
- Oracle provides 3 static public IP address
The minimum boot volume you can assign is 50GB, which means to utilize all the free VM limits fully, you can create up to 4 VM with 50GB boot volume each, or 1 VM with 100GB plus 2 VM with 50GB each, example:
- 2x VM with 2 ARM CPU 12GB RAM + 2x VM with 1 Shared AMD CPU 1GB RAM
- 1x VM with 4 ARM CPU 24GB RAM + 2x VM with 1 Shared AMD CPU 1GB RAM
You can, of course, setup other combinations with the free options. However, the limiting factor is most likely to be the free boot volume and the minimum boot volume of 50GB each.
Requirements for Oracle Cloud Account
- Valid Credit Card [Required by Oracle to prevent abuse]
- Registration while using residential IP [Turn off VPN, or they will decline your account]
I have tried myself it seems they will decline your registration if you use a debit card or any other type of prepaid card, such as a virtual credit card.
However, there’s no need to worry about surprise charges, Oracle Cloud won’t charge you unless you explicitly click upgrade your account.
Steps to Create an Oracle Free Tier Account
Once we have everything ready, we can move on to the account registration process. Do note that if some error occurs or if the registration process is interrupted, you will need to start again with a different email address (or use Gmail dot alias).
Go to the Oracle Cloud website and click the sign-up or start for free button, then fill up your email and name and wait for the verification email.
Once you click the verification link, you will then proceed to set up your username and password. The most important thing here is to choose your Home region wisely, as they can’t be changed for Free resources.
Finally, in the last step, you will enter your credit info to verify your account, putting a dollar on hold on your credit card, and they do this periodically to ensure your credit card is not some disposable credit card. If they fail to do so at a later date, they might cancel your account.
Once you get to this page, you will just wait for about an hour or so until your account is activated. Then you can navigate to the instances page and start deploying your free VM.
Solution for Out of Capacity in Availability Domain Error
If you encounter the above error while creating your free VPS, don’t panic, it is normal as Oracle probably has only allocated limited resources to give for free.
This means you will have to wait until there’s a new release of free resources, such as when someone deletes their VPS. However, it would be time-consuming to retry the creation process manually.
Luckily someone has written a small PHP script that utilizes the Oracle Cloud API to create VPS.
To use the script, you will need to have a web environment set up, the easiest way is to use a cheap VPS with hourly billing such as Digital Ocean to run the script 24/7 until your VPS is created.
On average, the time it took me to get my ARM instances created could take around 24~72 hours, but this varies depending on your account home region.
Using Script to Create a Free Cloud VPS Server
I’m going to use my Google Cloud free VPS for this as I already had PHP and composer installed on it. If you can’t get a VPS for this, you can install Laragon on your Windows machine, then use schedule task and PowerShell to invoke your PHP script too.
Create an API key that is required when calling the Oracle Cloud API endpoint. You can do that by visiting https://cloud.oracle.com/identity/domains/my-profile/api-keys
Make sure to download the private key file and save everything shown after you click the add button. You will need this in the next step.
We will proceed to set up the PHP script, but first, ensure you already have PHP and composer installed. If not, this is how you can install it:
# Install PHP and required extention, also install git and unzip
sudo apt install php php-curl git unzip
# Download composer installer
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
# Verify if PHP and Composer is working
Then we will download the PHP script, change the environment variable, and then set up cronjob once we confirm it’s working as intended.
git clone https://github.com/hitrov/oci-arm-host-capacity.git
cp .env.example .env
Now you use nano or vim to edit the .env file. With the API key and info you get in step 1 you can fill up the variables OCI_REGION, OCI_USER_ID, OCI_TENANCY_ID, and OCI_KEY_FINGERPRINT.
As for OCI_PRIVATE_KEY_FILENAME, you can either upload the private key file you downloaded in the first step or just open it with a text editor, copy the entire private key, then create key.pem in your VPS, then put the absolute path to that key.pem file.
You also need to define the SSH public key in OCI_SSH_PUBLIC_KEY, which you will be used to authenticate yourself when ssh to the VPS.
You can either use the Oracle Cloud VPS creation page generated SSH key or just generate one using your VPS, but make sure to save them for accessing your VPS. To generate with VPS, just use this command:
# If your press enter twice, your private key would be generated in ~/.ssh/id_rsa and your public key ~/.ssh/id_rsa.pub
# We would print your public key and you can copy that into OCI_SSH_PUBLIC_KEY
Now we will still need OCI_SUBNET_ID, OCI_IMAGE_ID, and OCI_AVAILABILITY_DOMAIN. To find these, we have to go to the VPS creation page on Oracle and fill up everything as we are creating VPS normally.
The most important part here is just selecting the OS, the default would be Oracle Linux, but you can also select alternative operating systems such as Ubuntu or CentOS.
Now just before you click the “Create” button, press F12 and go to the network tab, then press the “Create” you are probably going to get the out of capacity error here, which is expected.
But you should be able to find there’s a POST request to the /instances/ endpoint, you should be able to get the rest of the values you need in the payload.
Finally, copy those values into OCI_SUBNET_ID, OCI_IMAGE_ID, and OCI_AVAILABILITY_DOMAIN. The rest of the values in the env file is self-explanatory, but if you are not sure, take a look at my env file:
If you follow the same value I use in the above example, which means you will create 2 instances, each with 2 ARM CPUs, 12GB RAM, and 50GB boot volume.
And you probably notice that you can define a Telegram bot token and your own ID to notify yourself when the VPS is created, it is optional, but it’s helpful for me.
Once you are done setting up the environment file, simply invoke the PHP script to see confirm it’s working.
# This is most likely the response you will get, which mean it's working
"message": "Out of host capacity."
We’ll just have to set up a cronjob to invoke this PHP script until we get our free VPS created. To do that, run “crontab -e”, then append the following line (make sure to change to your own path):
* * * * * /usr/bin/php /root/oci-arm-host-capacity/index.php >> /root/oci-arm-host-capacity/log
That’s it! Now just sit back and wait until your VPS is ready, then you can connect and manage your virtual machine using software like Putty.
What Can You Host With the Oracle Cloud Server? Is It Really Free?
While this is an always free service offer by the Oracle virtual cloud platform, it is important to know that in the first 30 days your account is actually in a free trial and comes with a $300 trial credit, and anything you create without having the “Always Free” tag on it will be disabled when the trial ends, this includes the ARM instances.
Luckily the boot volume within the always free resources limit will not be deleted, so you can just setup new ARM instances after the trial period with the existing boot volume, so your project’s application such as WordPress will not be lost.
However, we do not recommend hosting important projects such as your business website as there are many complaints about the free resources being revoked by Oracle without any warnings.
If you want a consistent web host, consider our WordPress optimization and hosting services that aim to give your visitor the best user experience.