Technomancer’s Guide to Escaping the Corporate Daemons: Self-hosting WordPress on Hetzner with Kamal

Greetings, fellow sages of the digital realm! The winds of change are blowing through the WordPress ecosystem, and not all of them smell sweet. The recent actions of the Corporate Daemon known as Matt Mullenweg against WPEngine have sent ripples through our mystical community. But fear not, for I bring you arcane knowledge to break free from these ethereal chains.

TLDR; For the Impatient Apprentices

  1. Journey to the Hetzner realm. Establish your presence and conjure a server based on your traffic divinations.
  2. Summon Ruby to your local sanctum:
    • Mac Wizards: brew install ruby
    • Windows Warlocks: choco install ruby
  3. Mac Mages, inscribe these runes in your .zshrc grimoire:
    if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
        export PATH=/opt/homebrew/opt/ruby/bin:$PATH
        export PATH=`gem environment gemdir`/bin:$PATH
    fi
    
  4. Channel the essence of Kamal: gem install kamal
  5. Clone the sacred repository. Alter the deploy.yaml scroll, replacing YOUR_SERVER_IP with your server’s astral coordinates and YOUR_DOMAIN with your chosen ethereal address.
  6. Commit your changes to the Git-hive mind.
  7. Whisper these secrets to your environment: KAMAL_REGISTRY_PASSWORD, WORDPRESS_DB_PASSWORD, MYSQL_ROOT_PASSWORD, WORDPRESS_DB_HOST, WORDPRESS_DB_USER, and WORDPRESS_DB_PASSWORD
  8. Invoke the setup ritual: kamal setup
  9. Align your domain’s DNS ley lines to the server via an A record.
  10. Visit your domain and complete the WordPress initiation rites.

Rejoice, for you have severed the strings of the Corporate Puppet Masters!

The Technomancer’s Manifesto

In the neon-lit back alleys of the internet, where code meets chaos, I stumbled upon a revelation. The WordPress community, powering 40% of the known web, needed a way to break free from the shackles of corporate hosting. It is time for us to take control.

Embarking on Your Mystical Journey

Step 1: Summoning Your Digital Familiar

Venture into the ethereal planes of Hetzner. Create your astral projection (account), initiate a project, and select a machine to house your digital essence. Choose wisely based on the expected traffic to your mystical domain:

  • Moderate Traffic (10,000 to 50,000 daily pilgrims): Seek a familiar with 4-8 CPU cores, 16-32 GB of mana (RAM), and 240+ GB of astral storage (SSD/NVMe). The cpx41 familiar (~$25/moon cycle) should serve you well.
  • Lesser Traffic: Smaller familiars can be summoned for as little as $4 per moon cycle.

You’ll also need to forge a pact with the Docker Hub and obtain an access token. Create a repository for your WordPress image in this ethereal plane. This guide will grant you freedom whether you are summoning Headless WordPress or using it in its standard incantation. If you do happen to be running Headless, it makes even more sense to host yourself as the supposed benefits of many of these Daemonic entities don’t even apply to you.

Step 2: Invoking Ruby, the Gem of Power

To channel the energies of Kamal, you must first invoke Ruby. Follow the official grimoire or use these quick incantations:

  • Windows Warlocks (using Chocolatey): choco install ruby
  • Mac Mages (using Homebrew): brew install ruby

Step 3: Channeling Kamal, the Deployment Djinn

With Ruby at your command, summon Kamal by chanting: gem install kamal

Congratulations, technomancer! You’ve completed the most arduous part of our mystical journey.

Step 4: Crafting Your WordPress Sanctuary

  1. Create a new ethereal space: mkdir nerdpress && cd nerdpress
  2. Initialize the Git-hive mind: git init
  3. Commit your first thought-form: git add . && git commit -am "init commit"
  4. Invoke Kamal’s initialization ritual: kamal init

For those seeking a shortcut through the astral plane, simply clone this pre-prepared sanctuary.

Step 5: Attuning Your Deployment Scroll

Open the deploy.yaml scroll and replace all instances of YOUR_SERVER_IP with your Hetzner server’s astral coordinates. Also, replace YOUR_DOMAIN with the ethereal address you wish to bind to this sanctuary. Remember to immortalize your changes with git as Kamal uses it’s wisdom to guide it.

Step 6: Whispering Secrets to the Void

Create a .env scroll to hold your mystical secrets:

export KAMAL_REGISTRY_PASSWORD="DOCKER_HUB_ACCESS_TOKEN" 
export WORDPRESS_DB_PASSWORD="a_good_password"
export MYSQL_ROOT_PASSWORD="a_good_password"
export WORDPRESS_DB_HOST="YOUR_SERVER_IP"
export WORDPRESS_DB_USER="some_wordpress_user"
export WORDPRESS_DB_PASSWORD="a_good_password"

Breathe life into these secrets: source .env

Step 7: The Grand Summoning

Initiate the ritual with the incantation: kamal setup

This will:

  • Establish a psychic link (SSH) with your server
  • Summon Docker to your realm
  • Craft and manifest your image
  • Secure your sanctuary with SSL wards
  • Create a load balancer for seamless transitions
  • Conjure a separate vessel for your database
  • Breathe life into your digital sanctuary

Step 8: Aligning the Cosmic DNS

Point your domain to the server’s astral coordinates using an A record. The ley lines of the internet will soon converge on your new sanctuary.

Step 9: The Final Initiation

Visit your domain and complete the sacred WordPress setup ritual.

Behold, technomancer! You’ve successfully escaped the grasp of the Corporate Daemons. Your WordPress sanctuary now floats freely in the digital ether, untethered from the whims of those who would seek to control it.

May your newly liberated WordPress site resonate at the perfect frequency for your audience.

Now go forth and create, free from the shackles of managed hosting! The spirit world of the web awaits your contributions.

The Ephemeral Nature of Digital Realms: A Word of Caution

Hark, wise sage! Before you venture too deep into your newly crafted digital sanctuary, heed this crucial warning from the annals of technomancy:

The realm you’ve conjured, while powerful, exists in a state of flux. Like whispers in the wind or ripples in a pond, the data within your server is ephemeral - a temporary manifestation in the grand tapestry of the internet.

To anchor your creations in the sea of data, to give them permanence beyond the ebb and flow of server restarts and cosmic disturbances, you must perform one final ritual:

The Rite of Volume Binding

  1. Journey once more to the Hetzner control panel, your gateway to the server cosmos.
  2. Seek out the “Volumes” section, where the building blocks of data persistence reside.
  3. Summon a new volume, a vessel to hold your digital essence. Name it wisely, for names hold power (it will be whatever comes after /mnt/).
  4. Once created, bind this volume to your server. The mystical path it shall occupy is /mnt/wordpress.

With this volume in place, modify your deploy.yaml scroll. Add these lines of power under the volumes section:

volumes:
  - "/mnt/wordpress:/var/www/html"

This incantation ensures that your WordPress files, your digital lifeblood, are stored in a realm beyond the ephemeral confines of your server’s temporary existence.

Remember, O Technomancer, that without this ritual, your creations may vanish like mist in the morning sun upon server restarts or redeployments. Your posts, your media, your very digital essence - all could be lost to the void.

By binding your data to this persistent volume, you ensure that your WordPress sanctuary endures, a beacon of stability in the ever-shifting landscape of the internet.

Perform this rite, and rest easy knowing that your digital legacy is secured against the capricious nature of cloud servers and the fickle whims of the tech gods.

May your data persist, your uptime be eternal, and your WordPress sanctuary flourish in the fertile grounds of self-hosted freedom!