Dev Ops for WordPress Part Three

Trellis

Here are the steps to get up and running with Trellis.

For further information, please visit the Trellis documentation or visit the roots discourse – https://discourse.roots.io/

Local development setup

Create a directory on your local computer, 

mkdir yoursite.com && cd yoursite.com

Make sure you have write permissions to the folder then grab a copy of Trellis from the git repository.

git clone --depth=1 git@github.com:roots/trellis.git && rm -rf trellis/.git

Do the same for Bedrock

git clone --depth=1 git@github.com:roots/bedrock.git site && rm -rf site/.git

Edit the development sites file

trellis/group_vars/development/wordpress_sites.yml

In this file, replace any reference to “example” with the correct name of your site.

Edit the development vault file

trellis/group_vars/development/vault.yml

Again, change example to the correct site name and change any of the development passwords if required.

Change to the trellis directory in your terminal

cd yoursite.com/trellis

then run the vagrant up command

vagrant up

Enter your administrator password when requested. Then sit back and allow the magic to happen. Your dev site will be ready in between 0-10 time units. How does that even work? Well, I’m not going to go into it here, but it does! Most times. Unless you have permission issues or other minor tweaks that need to be made. A bit of googling will normally get things flowing, but drop me a comment if you get any weird errors 🙂

Staging / Production

Using vi

vi is a text editor originally developed for UNIX but now included with Linux distributions and macOS.

It will take a little while to memorise some of the vi commands, but stick with it. Learning vi will greatly speed up simple file edits both for your local dev environment (if you are on a mac) and on your Linux server.

Its strength lies in being able to make quick edits to files without having to load big IDEs

vi is a modal editor with two modes, normal mode and insert mode. In normal mode key presses are interpreted as commands. In insert mode, text in the file can be manipulated.

To change between the two modes use press

i

to switch to insert mode then

esc

to move back to normal mode.

Here are some more useful vi commands that will make editing files on Linux quick and easy:

Normal Mode

G – Move cursor to the end of the file
1G – Move cursor back to the beginning of the file
dd – delete line
3dd – delete 3 lines (substitute 3 for any number of lines)
:q – Quit, i.e. close the file
:qs – Quit and save
:q! – Quit and do not save

Insert mode

i – insert text before cursor
a – insert text after cursor
A – insert text at the end of the line
Esc – Leave insert mode

DevOps for WordPress Part Two

Today is V-Day. I think my next sentence contains the most Vs in any sentence in the history of the English language.

In this post I examine Vagrant, Varying Vagrant Vagrants and Variable VVV and how they can be used to simplify development environment setup.

Yes, really, those are their real names.

Virtualisation is a key component of  DevOps for local development environments. Virtualising your dev setup provides a number of benefits including ease of replication and an increased ability to automate repetitive tasks.

These three tools, used together, provide an automated process for quickly and simply creating local virtual development environments for WordPress.

Vagrant

Vagrant is an open source software tool to create and manage local development environments. Vagrant is used in conjunction with other virtualisation software such as VirtualBox or VMware.

Varying Vagrant Vagrants

Varying Vagrant Vagrants is an open source vagrant configuration tailored for WordPress development. VVV includes required software for WordPress development including NGINX as the webserver, MariaDB for the database and PHP.

Variable VVV

Variable VVV builds on top of Varying Vagrant Vagrants to further improve and automate the setup process.

Set up a local dev environment using Variable VVV.

Install all the required software:

  1. Vagrant
  2. Varying Vagrant Vagrants
  3. Variable VVV

Once all the requirements are installed, setting up a development WordPress site is as easy as browsing to the local vagrant directory directory, in my case:

/usr/local/bin/vagrant-local/www

and typing

vv create

Variable VVV will then ask a series of questions about your WordPress install and, all things going well, set up a working WordPress development environment for you.

Image showing Variable VVV set up using terminal on a Macbook

DevOps for WordPress Part One

In this series I examine a number of options for setting up working DevOps processes in a WordPress development context. Through a number of examples I demonstrate how DevOps can be utilised to improve our development practice by promoting a professional, structured approach to managing WordPress development.

But first, a quick introduction. What is DevOps other than a pretty cool sounding name reminiscent of SpecOps?

DevOps is a term covering a wide range of tools, technologies and processes. Expanding the word helps to understand its meaning. DevOps stands for Development Operations and revolves around the tasks necessary to efficiently manage the development process. A particular focus of DevOps is the automation of regular activities.

DevOps can provide benefits to processes throughout the entire development infrastructure. From setting up a local development environment to managing releases to the production environment.

There are many reasons to include DevOps in your WordPress development workflow. These benefits include:

  • Increased speed and consistency of development
  • Increased efficiency and reliability of deployment
  • Improved quality of final product
  • Increased speed of delivering final product

The main areas I focus on are:

  • Development
  • Testing
  • Deployment

DevOps is not a quick fix. It requires careful planning and preparation with a particular motivation to develop and deploy in a structured and organised manner.  If your aim is to quickly set up a one-off website which will require little or no maintenance then spending time on a DevOps set up will likely be overkill. However, if you need a repeatable and professional practice for consistently developing quality websites then it is going to be time well spent.

While the initial setup and configuration will take some thought and time, the benefits will soon make themselves apparent.

Tools

I will examine and demonstrate a number of tools available for DevOps processes. These will include:

Vagrant
Varying Vagrant Vagrants
Variable VVV*
Roots Trellis and Bedrock
PHPUnit

* Really? Variable Varying Vagrant Vagrants?!