Deploy WordPress in under a minute with Hasura

This post will help you deploy a WordPress app onto the cloud in just a few clicks, using Docker and Hasura.

Praveen Durairaju
4 min readMar 23, 2017

Note: The instructions in the post works only for v0.14 version of Hasura. Updated instructions for v0.15 version is here.

WordPress is an extremely popular open source content management system (CMS) based on PHP and MySQL.

Through this tutorial, we’ll show you how to deploy WordPress using official Docker images of MySQL and WordPress.

Hasura is the easiest way to deploy WordPress — let’s see how to do that in two steps.

1. Create a Hasura project

First, get yourself a free Hasura project by registering on https://dashboard.hasura.io and clicking on the ‘Activate’ button.

2. Install WordPress using a Docker image

Prerequisite: We need to have a MySQL database up and running for WordPress to work.

MySQL Setup

Let’s create a new custom service in the Hasura project console for setting up MySQL.

Note: Any docker image can be deployed as a service on a Kubernetes cluster using the Hasura project console.

Create a new custom service in the project console. Configure the service with a name (the service is also deployed under a subdomain with the same name). Let’s use “mysql” as the service name.

Under Image details, enter mysql:latest and container port as 3306. (Note: MySQL runs on port 3306). Depending on whether you want to persist/backup this database, enable data persistence and enter the path as “/var/lib/mysql”.

Under environment variables, create a new variable named “MYSQL_ROOT_PASSWORD” and give it a value. (Since this is the root password, we recommend using something complex). In Advanced Settings, you can restrict the role to only “admin”, since you may not want to open up your database to the outside world.

Create Custom Service for MySQL

That’s it, just hit ‘Create’, and MySQL container is up and running!

WordPress Setup

Now that the prerequisite MySQL has been installed, we can proceed with the WordPress installation.

Follow the same steps of creating a new custom service like we did above for MySQL, but this time for WordPress.

Enter “wordpress” for your custom service name, “wordpress:latest” for the docker image and container port as 80.

Depending on whether you want to persist your wordpress html folder, enable data persistence with container path as “/var/www/html”.

Under Environment variables, enter the env “WORDPRESS_DB_HOST” with value “mysql.default:80”; Here “mysql” is the custom service name and it is running on “default” kubernetes namespace. Now here we give port as 80 because the custom service is exposed to port 80 for outside connections, even though MySQL runs on 3306 internally inside the container.

Enter the env “WORDPRESS_DB_PASSWORD” with its value — Remember the password you entered while creating the mysql service?

Create Custom Service for WordPress

Click on “Create” and you are done! WordPress has been successfully deployed.

You can visit the external endpoint of the wordpress custom service to proceed further with the installation of WordPress.

WordPress Installation — Step 1

Select the language of choice and click on Continue.

WordPress Installation — Step 2

Enter the site details along with credentials for admin.

WordPress Admin Interface

You will be redirected to the Admin interface once you create the credentials. You can now visit the blog directly using the external endpoint.

WordPress Deployed Successfully

Note: Generating SSL Certificates may take some time and hence the “https” link may not be instantly available. Meanwhile, feel free to use the http link for proceeding with the installation.

So to summarise, we just need to add two custom services in the Hasura Project Console (one for MySQL and one for WordPress), configure the appropriate port number and environment variables and you will be ready to go.

Hasura lets you instantly deploy 3rd party applications or quickly build your own apps (or both). Check it out here: https://hasura.io

--

--

Praveen Durairaju

Staff Developer Advocate @HasuraHQ. Tech Enthusiast. Twitter — @PraveenWeb