In today's digital landscape, self-hosting solutions have become increasingly popular among individuals and small businesses seeking greater control over their data and online presence. YunoHost, a versatile and user-friendly self-hosting platform, allows users to manage their own server and host various applications effortlessly. Coupled with the cost-effective and robust infrastructure of Oracle Cloud Infrastructure (OCI), specifically its Free Tier Ampere server, you can establish a powerful and scalable self-hosting environment without breaking the bank.
This article will guide you through the process of setting up YunoHost on an OCI Free Tier Ampere server, leveraging its high-performance Arm-based architecture. We will cover everything from creating an OCI account and setting up your Ampere instance to installing and configuring YunoHost. Whether you're a seasoned sysadmin or a beginner exploring the world of self-hosting, this comprehensive guide aims to provide clear, step-by-step instructions to help you get YunoHost up and running smoothly on OCI's free tier offering.
By the end of this article, you'll be equipped with the knowledge and tools to deploy and manage your own YunoHost server, enabling you to host applications, websites, and services with ease and confidence. Let's dive in and unlock the potential of self-hosting with YunoHost on OCI Free Tier Ampere server!
Services available on Oracle Cloud Free Tier
For Oracle Cloud Infrastructure (OCI) Free Tier instances, you typically have access to the following:
vCPU and Memory: You get up to 4 OCPU (equivalent to 8 vCPUs) and 24 GB of memory in the free tier, but for a more typical free-tier configuration, you can use a smaller instance like 1 OCPU (2 vCPUs) and 6 GB of RAM. This is sufficient for running YunoHost and several applications.
Block Storage: OCI Free Tier provides 200 GB of block storage, which can be attached to your Ampere A1 instance. This is useful for storing your application data and backups.
Bandwidth: OCI offers 10TB/month bandwidth allocations on the Free Tier, which is adequate for most small to medium self-hosting needs.
Instance Configuration
This configuration is suitable for lightweight applications, small-scale development, and self-hosting solutions like YunoHost.
Sign Up for OCI Free Tier
If you haven't already, sign up for the OCI Free Tier. You’ll need to provide some basic information and a payment method.
Create a Compute Instance
- Go to the OCI Console.
- Navigate to the "Compute" section and click on "Instances."
- Click "Create Instance."
Select Instance Type
- Choose "VM.Standard.A1.Flex" under the "Shape" configuration.
- Select the configuration that best suits your needs. For running YunoHost, a configuration with 4 OCPU (8 vCPUs) and 24 GB of RAM is a beast.
Configure Networking
- Set up a Virtual Cloud Network (VCN) if you don’t have one already.
- Configure the subnet and other networking settings as required.
Generate SSH-2 RSA key (Required)
- You may use PuTTYgen to generate an SSH keys (private & public).
- In the "Add SSH Keys" section, click on "Paste Public Keys."
- Paste the public key text you copied from PuTTYgen into the box.
- Ensure the key format is correct (should start with "ssh-rsa").
Attach Storage
Attach a block storage volume if needed. The Free Tier offers 200 GB, which can be split into multiple volumes if necessary.
Launch Instance
Complete the remaining configuration steps and launch your instance.
Things to Double-Check After Instance Creation
Once you have created your Ampere A1 Compute instance on OCI's Free Tier, there are several critical components you should double-check to ensure your instance is accessible and properly configured:
Route Table
Purpose: Ensures that traffic can properly route between subnets and the internet.
Steps to Check:
- Navigate to the "Networking" section in the OCI Console.
- Select your Virtual Cloud Network (VCN).
- Click on "Route Tables" in the VCN menu.
- Verify that there is a route rule allowing traffic to the internet through your Internet Gateway. It should look something like:
- Target Type: Internet Gateway
- Destination CIDR Block: 0.0.0.0/0
- Compartment: (Your compartment)
- Internet Gateway: (Your Internet Gateway name)
Common Issues: Missing or incorrect route rules can prevent your instance from accessing the internet.
Internet Gateway
Purpose: Enables your instance to communicate with the internet.
Steps to Check:
- Go to the "Networking" section in the OCI Console.
- Select your VCN.
- Click on "Internet Gateways" in the VCN menu.
- Ensure that an Internet Gateway is created and associated with your VCN.
- Verify that the Internet Gateway is correctly attached to the route table.
Common Issues: Not having an Internet Gateway, or it not being properly associated, will block internet traffic.
Security Lists and Network Security Groups
Purpose: Ensure that the correct ports are open for incoming and outgoing traffic.
Steps to Check:
- Under the VCN, navigate to "Security Lists" or "Network Security Groups" (NSGs).
- Verify that the security lists or NSGs associated with your subnet allow traffic on the necessary ports (e.g., HTTP/HTTPS ports 80/443, SSH port 22).
- Add rules as necessary to permit required traffic.
Example Rules:
- Ingress Rule: Allow TCP traffic on port 22 (SSH) from
0.0.0.0/0. - Ingress Rule: Allow TCP traffic on port 80 (HTTP) from
0.0.0.0/0. - Ingress Rule: Allow TCP traffic on port 443 (HTTPS) from
0.0.0.0/0.
Connect to OCI Instance with SSH Keys Using PuTTY (ubuntu)
Here's a step-by-step guide to connect to your OCI instance using PuTTY on Windows:
Open PuTTY
Launch PuTTY from your Start menu or desktop.
Session Configuration
In the PuTTY Configuration window, under the "Session" category, paste the public IP address of your OCI instance into the "Host Name (or IP address)" field.
Auto-login Username
- Expand the "Connection" category on the left sidebar.
- Go to "Data."
- In the "Auto-login username" field, type
ubuntu
SSH Key Authentication
- Expand the "SSH" category under "Connection."
- Click on "Auth."
- In the "Authentication parameters" section, click on "Browse" next to "Private key file for authentication."
- Select the
.ppkfile you saved earlier with PuTTYgen.
Save Session Configuration (Optional)
- Go back to the "Session" category.
- In the "Saved Sessions" field, enter a name for this configuration (e.g., "OCI_YunoHost").
- Click "Save" to store the session configuration for future use.
Connect to Instance
Click "Open" to start the SSH connection.
Accept Security Alert
- If this is your first time connecting to the instance, a PuTTY Security Alert will appear.
- Click "Connect Once" to accept the host key and continue the connection.
Access the Instance
- After successfully connecting, you should see a terminal window prompting you for login.
- Since you've set the auto-login username, you should be directly logged in as the
ubuntuuser.
Install Firewalld
While ufw (Uncomplicated Firewall) is popular in some other Linux distributions, especially those based on Ubuntu, OCI has chosen to standardize on firewalld to align with its infrastructure and support model.
Update the Apt List
sudo apt updateInstall Install the firewalld package
sudo apt install firewalld -yEnable HTTP and HTTPS Connections
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanentReload the Firewall
Apply the changes by reloading the firewall
sudo firewall-cmd --reloadCheck ports status: You may use https://portchecker.co/ to ensure that all ports are reachable in 0.0.0.0/0Upload Public Key to GitHub
This will be the easiest method to add your public key in the Instance.
Log In to GitHub
- Go to GitHub and log in with your account.
Navigate to SSH and GPG Keys
- Click on your profile picture in the upper-right corner.
- Select "Settings" from the dropdown menu.
- In the left sidebar, click on "SSH and GPG keys."
Add a New SSH Key
- Click the "New SSH key" button.
- Enter a descriptive title for the key in the "Title" field (e.g., "Debian Server Key").
Paste the Public Key
- Open your public key file (usually ending in
.pub). - Copy the entire content of the file.
- Paste the copied key into the "Key" field on GitHub.
Save the Key
- Click the "Add SSH key" button to save your public key.
Replace Canonical Ubuntu 22.04 with Debian 11
YunoHost is specifically designed to work with Debian, which is why replacing Ubuntu with Debian is necessary for a successful installation. Debian's stability and compatibility with YunoHost's requirements make it the preferred choice for hosting this self-management platform.
Download and Prepare the Script
- Open a terminal on your Ubuntu machine.
Download the script with curl
curl -fLO https://raw.githubusercontent.com/bohanyang/debi/master/debi.shMake the script executable
chmod a+rx debi.shExecute the script to replace Ubuntu with Debian 11
sudo ./debi.sh --version 11 --authorized-keys-url https://github.com/<github username>.keysNote: Replace <github username> with your actual GitHub username. Make sure your public SSH key is uploaded to your GitHub account.Reboot the System
- After running the script, reboot your system to apply changes:
sudo shutdown -r nowWait for the System to Reboot
- Allow 5-7 minutes for the system to reboot and complete the transition from Ubuntu to Debian.
Note: You will notice on your OCI dashboard that the metrics show no data for the Instance. This is normal and indicates that Ubuntu has been successfully replaced with the new Linux distribution on the Instance.
Connect to OCI Instance with SSH Keys Using PuTTY (debian)
Here's a step-by-step guide to connect to your OCI instance using PuTTY on Windows:
Open PuTTY
- Launch PuTTY from your Start menu or desktop.
Session Configuration
- In the PuTTY Configuration window, under the "Session" category, paste the public IP address of your OCI instance into the "Host Name (or IP address)" field.
Auto-login Username
- Expand the "Connection" category on the left sidebar.
- Go to "Data."
- In the "Auto-login username" field, type
debian
SSH Key Authentication
- Expand the "SSH" category under "Connection."
- Click on "Auth."
- In the "Authentication parameters" section, click on "Browse" next to "Private key file for authentication."
- Select the
.ppkfile you saved earlier with PuTTYgen.
Connect to Instance
Click "Open" to start the SSH connection.
Accept Security Alert
- If this is your first time connecting to the instance, a PuTTY Security Alert will appear.
- Click "Connect Once" to accept the host key and continue the connection.
Access the Instance
- After successfully connecting, you should see a terminal window prompting you for login.
- Since you've set the auto-login username, you should be directly logged in as the
debianuser.
Install Packages and YunoHost
By following these steps, you’ll install YunoHost and complete the setup for your server.
Update Package List and Install Essential Packages
sudo apt update && sudo apt install htop curl unzip tmux -yStart a tmux Session: Begin a new tmux session named yuno
tmux new -s yunoBecome Root
Switch to the root user
sudo -iInstall YunoHost
Run the YunoHost installation script
curl https://install.yunohost.org | bashComplete the Initial Configuration
- Open your web browser and navigate to your public IPv4 address to proceed with the YunoHost initial configuration.
Note: You will no longer be able to use "debian" as the username to log in via SSH. Instead, use the admin account that you created during the YunoHost web browser setup.
References
A huge shout-out to Yury Belousov for creating and sharing the invaluable GitHub Gist guide. Additionally, Brent Yang deserves significant recognition for developing the Debian script, which made this project possible and accessible for enthusiasts like me.