Deploying and Managing WordPress

Nov 27, 2023 by Rohit Ghumare
Deploying and Managing WordPress

In the digital era, where having an online presence is almost synonymous with having a tangible identity, the platform you choose to host and build your online space holds paramount importance. Initially conceived as a blogging platform, WordPress transcended those early bounds, morphing into a comprehensive website-building powerhouse. In this tutorial, we'll look at how to easily host a WordPress environment using Acorn, discuss getting started with WordpPress, and look at how it compares with other open source options on the market.

WordPress, an immensely popular CMS (Content Management System), is known for its flexibility and ease of use. In this tutorial, we'll explore how to deploy WordPress using the Acorn MariaDB service, utilizing Docker containers for a smooth and scalable setup. We’ll also delve into managing secrets securely within our deployment.

Deploying a Sandbox Wordpress Environment on Acorn

If you want to follow along with this tutorial, you can follow this link to deploy the Acorn Image I have written for WordPress in the Acorn sandbox. Acorn's sandbox is free to everyone, and allows you to run images for two hours before they are stopped. For WordPress it is especially nice because it includes a database service, a load balancer, and a public IP, all of which we will need. If you decide you want to run WordPress on an ongoing basis, you can upgrade your Acorn account to a paid Pro account, where you can pay as you go for the cloud resources to run WordPress.

Let’s start our tutorial by looking at the architecture and steps involved in deploying WordPress.

Understanding the Architecture:

wordpress-architecture.png

To run WordPress we need to deploy it onto a server, and expose it to the internet. We'll start by setting up a MariaDB Database and connect it to a Docker container running the WordPress software. We'll need to use a secret to ensure only WordPress can access the database.

  1. MariaDB Service on Acorn:
    • MariaDB, a robust and reliable database service, is the backbone of our WordPress installation. I've built this image to use the managed version of MariaDB that is part of Acorn, ensuring high availability and easy scalability as your website grows.
  2. Docker Containers:
    • Docker encapsulates the WordPress application and its dependencies into a portable container, making it easy to deploy, scale, and manage. I have written several docker images since the start of my career, and WordPress is my favorite as it’s the easiest and simplest to customize according to user needs.

  3. Secret Management:
    • Securely managing secrets, such as database credentials, is crucial for safeguarding your WordPress installation from unauthorized access. You can define secrets in Acorn images by customizing the Acornfile or using the Acorn UI.

Why WordPress?

  1. Versatility:
    • WordPress is no longer merely a blogging platform but a versatile website-building tool catering to various needs, from simple blogs to complex e-commerce websites and portfolios.
  2. Ease of Use and Accessibility:
    • Known for its user-centric interface, WordPress allows even the least tech-savvy individuals to create and manage their digital presence easily.
  3. Vast Repository of Themes and Plugins:
    • The WordPress repository's extensive array of themes and plugins facilitates endless customization and functionality extension, making it a playground for creativity.
  4. Community and Support:
    • The robust community surrounding WordPress provides an invaluable resource for learning, troubleshooting, and networking, a cornerstone of its enduring success.
  5. SEO and Mobile Responsiveness:
    • Built with SEO and mobile responsiveness in mind, WordPress ensures that your content reaches the intended audience effectively across all devices.

Install WordPress through Acorn Image:

● I've created a pre-built WordPress images with MariaDB as a Database; You can use it to deploy your WordPress with a single click.

Or you can use the Acorn CLI and the following commands

acorn login acorn run ghcr.io/rohitg00/wordpress:v1.0 acorn container run --name [container_name] [acorn_image]

If you want to explore more about creating Aocrnfiles and Acorn images or are interested in customizing our WordPress Acorn I have created a step-by-step guide to deploying WordPress.

Step-by-Step Deployment Guide:

I recommend creating a new directory for this demo because Acorn requires you to run the following commands inside the directory where the acornfile is present. An Acornfile is a file that describes how to launch containers and services on Acorn. It is very similar to JSON and YAML, and if you're already familiar with Docker or Docker Compose, you'll find it quite easy to understand.

Every Acornfile can be built into an artifact called an Acorn Image, which is a complete package of your application. It includes all the container images, secrets, data, nested Acorns, etc. in a single OCI image that can be distributed through a registry.

$ mkdir wordpress $ cd wordpress

Now, let's build our Acornfile for WordPress, starting with the database.

  1. Setting up Acorn MariaDB service:

    • Begin by creating a new database instance on the Acorn MariaDB service. Follow the on-screen instructions to configure your database, ensuring you securely note down the credentials.
    services: db: { image: "ghcr.io/acorn-io/mariadb:v0.1.0" serviceArgs: dbName: "wordpress" }
  2. Specifying the WordPress container and customizing environment variables:

    • We need to tell Acorn we want to run the official WordPress container image. WordPress has specific environment variable requirements that you can find in its official Docker image. We're defining here the ports we want to publish, the fact we're using MariaDB (which is a version of MySQL), and how we're going to connec to our instance of the database.
containers: wp: { image: "wordpress:latest" ports: publish: "80/http" env: { WORDPRESS_DB_CLIENT: "mysql" WORDPRESS_DB_HOST: "@{service.db.address}" WORDPRESS_DB_USER: "@{service.db.secrets.admin.username}" WORDPRESS_DB_PASSWORD: "@{service.db.secrets.admin.password}" WORDPRESS_DB_NAME: "@{service.db.data.dbName}" } }
  1. Secrets for securing your WordPress: [Optional]
    • Finally, we want to tell Acorn to create a secret password for WordPress to access our MariaDB instance.
secrets: { "WORDPRESS_DB_ROOT_PASSWORD": { type: "token" } }
  1. Now we have the final Acornfile ready!
containers: wp: { image: "wordpress:latest" ports: publish: "80/http" env: { WORDPRESS_DB_CLIENT: "mysql" WORDPRESS_DB_HOST: "@{service.db.address}" WORDPRESS_DB_USER: "@{service.db.secrets.admin.username}" WORDPRESS_DB_PASSWORD: "@{service.db.secrets.admin.password}" WORDPRESS_DB_NAME: "@{service.db.data.dbName}" } } services: db: { image: "ghcr.io/acorn-io/mariadb:v0.1.0" serviceArgs: dbName: "wordpress" }
  1. Deploying Acorn image for WordPress on MariaDB:
    • Once you've created the Acornfile in your directory, and downloaded the Acorn CLI, you can run the command below to create your Acornimage and deploy it to your Acorn sandbox.
acorn login acorn run -n wordpress .

Expected Output:

wordpress-expected-outputs.png

  1. Access WordPress in your browser

To Access the WordPress environment you've created, visit the Acorn dashboard and find the Wordpress deployment, where you'll find an endpoint that you can follow to access the WordPress server you've deployed. wordpress-language.png

wordpress-welcome.png

Congratulations! We have successfully installed WordPress with MariaDB on Acorn. Now you can select your language, create your account as the WordPress administrator, and begin setting up your own WordPress server.

wordpress-dashboard.png

Try selecting a theme from the free WordPress options and posting your first blog post. Once you get started with WordPress you'll find it is a rich and powerful platform for publishing web pages and blog posts, collaborating with others, and even selling goods and services through popular e-commerce plugins.

WordPress vs. other Blogging Platforms

Let's compare two other popular CMS platforms, Joomla and Drupal, and see how they stack up to WordPress

  • Ease of Use:
    • WordPress is often praised for its straightforward user interface compared to Joomla and Drupal, making it a more appealing choice for beginners.
  • Extensibility:
    • All three platforms offer a range of extensions, plugins, or modules. However, WordPress leads with a vast array of plugins and themes, making it easier for users to extend their site’s functionality and appearance.
  • Community and Support:
    • While Joomla and Drupal have substantial communities, the WordPress community is considerably larger, offering a wealth of tutorials, forums, and third-party services.
  • SEO Capabilities:
    • All three platforms are SEO-friendly, but with popular plugins like Yoast SEO, WordPress makes SEO implementation more straightforward.
  • Security:
    • Drupal is often praised for its robust security features, whereas WordPress and Joomla may require additional security measures or plugins to fortify site security.
  • Development Opportunities:
    • Drupal offers more advanced development opportunities for those with technical expertise, whereas WordPress provides a balanced approach, catering to both beginners and developers.

##Ghost, a simple alternative to WordPress

If you're looking for something less complicated than WordPress, consider Ghost, another open-source CMS that has become very popular in the last decade. I've created an Acorn Image to deploy Ghost in your sandbox, which you can use to compare the two popular website hosting platforms.

Conclusion

The journey from conception as a mere blogging platform to evolving into a robust website-building powerhouse encapsulates the essence of WordPress's transformative trajectory. Its adaptability, ease of use, and rich repository of themes and plugins make it a compelling choice for individuals and businesses alike.

This tutorial not only demonstrated a seamless WordPress deployment using Acorn MariaDB service and Docker containers but also highlighted its superiority when pitted against other notable platforms like Joomla and Drupal. The extensive community support, superior SEO capabilities, and a balanced approach towards catering to both beginners and seasoned developers further accentuate WordPress's appeal.

We explored Acorn and successfully wrote an Acornfile to demonstrate the WordPress setup, but this is just scratching the surface of what you can do with Acorn. You can explore the Acorn docs or find other interesting software to deploy in your Acorn Sandbox, sucha as a Minecraft server, or a meal planning app in the Acorn Library.

Header Photo by Justin Morgan on Unsplash


Rohit Ghumare is a developer advocate living in Mumbai, India. You can find him on X, LinkedIn or Github.