How To Install a WordPress Dev on Silverblue

Hello! Two things! First I haven’t touched PHP for at least 4 years (thanks Lord!) so I may write something terrible here, and corrections and better recommendations are welcome!

Second this is not a step by step guide, but something like a “path” to follow if you want to have a WordPress up and running in the easiest and fasterst way possible!

This story will only explain how to set up the development environment and not how to deploy in production. My self I consider an awful idea to open “home servers” to outside word. Here I just want a local version of “babydora.me” that I will later hopefully deploy on OpenShift :p

Get Docker

Silverblue (and Project Atomic in general) by default comes with Podman and Buildah pre-installed. The problem with Podman is that is missing Compose and it will add complexity to work without it. Therefore we will install Docker instead

I added the official Docker CE repo, I edited the repos to show on Fedora 28, since my Silverblue is version 29 and Docker doesnt support 29 yet, and I forced overlay2 on storage driver, that I dont’t think it was needed. Actually it is not needed to add the Docker repos at all. Just get Docker from Fedora default repos, even if it is a bit older version. All should work

Then:

$ rpm-ostree install docker-ce docker-compose

Don’t restart yet to apply the changes, because we will need a couple more things!

Get PHP

Before I install PHP as a LayeredPackage I tried to find some version management module. I only found PHPBrew that it needs to have PHP installed already anyway, so it didn’t quite help

The other solution to avoid to install PHP system wide was to fully work inside containers with interactive mode, but that reduces usability a bit. However that is your choice!

Fortunately we wont’ need lots of things

$ rpm-ostree install php-cli php-json php-mbstring php-simplexml

Now you should restart to apply the changes and continue the tutorial. As a Silverblue tip you can do:

$ sudo rpm-ostree ex livefs

That is supposed to apply the changes and mount the new image without restart. It is an experimental feature (ex) and it won’t work anyway in this case, so just restart :)

Get Composer

Then you need to install PHP Composer. Just follow the instructions on their official docs. It is like 3 minutes max to get it working!

Get Node

Install Node with NVM if you dont have it already, and also get Yarn

$ npm i -g yarn

Notice that $HOME is a symbolic link that Silverblue doesn’t like. Therefore:

BAD
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
--------------
GOOD
export NVM_DIR="/var/home/me/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

So by now you should have all the prerequisites to start: Docker, PHP-CLI, Composer, Node & NPM and Yarn

Get DevilBox

We now could create a Docker Compose our selves, but instead we will get DevilBox because it has an absolutely awesome configuration and it is four minutes setup, with zero prior experience!

Basically we only clone it and run a sudo docker-compose up inside the root directory!

Before remember to start Docker ofc!

$ sudo systemctl start docker

When it downloads all the containers we should see something like this on localhost:80

On DevilBox .env file I setup my paths like these:

HOST_PATH_MYSQL_DATADIR=/var/home/me/DevilBox/mysql
HOST_PATH_HTTPD_DATADIR=/var/home/me/DevilBox/www
etc

And I added babydora.me on /etc/hosts

127.0.0.1 babydora.me.loc

So my WordPress installation path looks like that

Which reminds me something important..

..Get WordPress!

I forgot about it, but we actually need that too! You can download stable releases of WordPress, but I got it directly from Github and at the moment is on version 5.0 alpha, and the biggest change from stable series 4 is a new editor, or that at least I read

You unzip inside htdocs as you set it on DevixBox, and then you can just hit it on web-browser and complete the installation

Get Sage Theme

All the above we installed like PHP and Node are needed for working with Sage theme. If you want to work with one of the default WordPress themes you don’t need to install any of those. Docker CE, Docker Compose & DevilBox are enough

As I said in the beginning of the article, I haven’t touched PHP or WordPress for ages, but I wanted a boilerplate theme to work with, and I found Sage to be the most popular with very active development

It looks like this!

To get it, is as simple as

$ cd ../babydora.me/htdocs/wp-content/themes
$ composer create-project roots/sage your-theme-name
$ yarn
Build Sage for Production

And editing is very simple. Docs on their Github!

The End

And that I guess was the easiest / fastest way to get a WordPress up and running on Silverblue! You should complete all the steps in under 30 minutes really!

Recommendations are welcome, but please don’t go on “Why WordPress!” for a blog! I’m not a PHP fan either, but WP makes sense for lots of reasons!