Hosting WordPress on Oracle Cloud Always Free (AMD Micro)


Prerequisites

  • An active Oracle Cloud account.
  • A domain name (registered at Porkbun or similar).

Yes, this guide was partly generated by AI (for formatting), specifically Gemini, but was fact-checked by me.


Phase 1: Create the VPS Instance (Oracle Cloud)

  1. Login: Go to the Oracle Cloud Console.
  2. Navigate: Go to Compute > Instances > Create Instance.
  3. Name: my-wordpress-server (or similar).
  4. Image & Shape:
    • Image: Change Image > Canonical Ubuntu 24.04 Minimal.
    • Shape: Change Shape > VM.Standard.E2.1.Micro (AMD, 1 OCPU, 1GB RAM).
  5. Networking:
    • Keep options as is, we’ll get an IP address later which won’t change
  6. SSH Keys:
    • Select “Generate a key pair for me” (or upload your own public key).
    • IMPORTANT: Click Save Private Key. Keep this safe; you cannot log in without it.
  7. Create: Click the Create button. Wait for the state to turn “Running” (Green).

Phase 2: Configure Networking (Open Ports 80/443) and IP

You must open the firewall in two places: the Oracle Network (VCN) and the Server itself.

A. Oracle Cloud Console (VCN)

  1. On the Instance details page, click the link under Subnet (e.g., subnet-2026...).
  2. Click Default Security List for…
  3. Click Add Ingress Rules.
  4. Add the following rule:
    • Source CIDR: 0.0.0.0/0
    • IP Protocol: TCP
    • Destination Port Range: 80,443
  5. Click Add Ingress Rules.

B. Server Internal Firewall (IPTables)

Connect to your server via SSH and run these commands to insert allow rules at the top of the list:

sudo apt update
sudo apt install iptables-persistent -y
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT
sudo netfilter-persistent save

C. IP Address Assignment

  1. Search for “Reserved Public IP” in the search bar, click it.
  2. Click Reserve Public IP
  3. Give it a name, eg, WordPress
  4. Reserve it with the button on the bottom left.
  5. Go to Compute > Instances.
  6. Click on your instance name (my-wordpress-server).
  7. Scroll down to the Resources menu on the left side of the page.
  8. Click Attached VNICs.
  9. You will see a table with one item (usually named the same as your instance). Click the name of that VNIC (e.g., my-wordpress-server).
  10. Find the IPv4 Configuration:
  11. On the new page that loads, look at the Resources menu on the left again.
  12. Click IPv4 Addresses.
  13. Swap the IP:
  14. You will see a row representing your server’s internal and external IP.
  15. Click the three dots (⋮) on the right side of that row.
  16. Select Edit.
  17. In the popup window, look for “Public IP Type”. Change it from “Ephemeral Public IP” to Reserved Public IP.
  18. A dropdown menu will appear. Select the IP you just named (e.g., WordPress).
  19. Click Update.

Phase 3: System Prep

Since the server only has 1GB RAM, we must add a Swap file to prevent crashes.

1. Install Essentials

sudo apt update && sudo apt upgrade -y
sudo apt install nano wget curl net-tools -y

2. Create 2GB Swap File

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Phase 4: Install LAMP Stack (Linux, Apache, MySQL, PHP)

1. Install Apache

sudo apt install apache2 -y
sudo systemctl enable apache2

2. Install PHP & Extensions

sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-xml php-mbstring php-xmlrpc php-zip php-soap php-intl -y
sudo systemctl restart apache2

3. Install MySQL

sudo apt install mysql-server -y

4. Secure MySQL

sudo mysql_secure_installation

Settings: Validate Password (No), Remove anonymous (Yes), Disallow root remote (Yes), Remove test DB (Yes), Reload tables (Yes).


Phase 5: Create Database

Run commands one by one. Log into MySQL with sudo mysql -u root -p and run the following (replace ‘StrongPassword123’ with your own):

CREATE DATABASE wordpress;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'StrongPassword123';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Phase 6: Install WordPress (Root Directory)

cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz

# Move files to main folder
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz index.html

# Set Permissions
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Phase 7: Optimize Apache (Prevent Crashes)

Edit the configuration file: sudo nano /etc/apache2/mods-enabled/mpm_prefork.conf

Delete the existing content and replace it with this:

<IfModule mpm_prefork_module>
    StartServers            2
    MinSpareServers         2
    MaxSpareServers         5
    MaxRequestWorkers       10
    MaxConnectionsPerChild  1000
</IfModule>

Restart Apache: sudo systemctl restart apache2


Phase 8: DNS Setup (Porkbun)

  1. Log in to Porkbun > Domain Management > DNS.
  2. Delete default parking records.
  3. Add Root Record:
    • Type: A
    • Host: (Leave Blank)
    • Answer: YOUR_ORACLE_IP
  4. Add WWW Record:
    • Type: CNAME
    • Host: www
    • Answer: yourdomain.com

Phase 9: SSL Certificate (HTTPS)

1. Install Certbot:

sudo apt install certbot python3-certbot-apache -y

2. Pre-configure Apache names: sudo nano /etc/apache2/sites-available/000-default.conf

DocumentRoot /var/www/html
ServerName yourdomain.com
ServerAlias www.yourdomain.com

3. Generate Certificate (Select “Redirect” when asked):

sudo systemctl reload apache2
sudo certbot --apache

Phase 10: Auto-Updates & Maintenance

# Set Timezone
sudo timedatectl set-timezone America/New_York

# Install Unattended Upgrades
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure --priority=low unattended-upgrades

Edit the schedule: sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";

Phase 11: Final WordPress Setup

  • Browser: Go to https://yourdomain.com.
  • Language: English.
  • Database Info:
    • Name: wordpress
    • User: wp_user
    • Password: StrongPassword123
    • Host: localhost


Leave a Reply

Your email address will not be published. Required fields are marked *