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

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?!

WordPress Permissions

WordPress permissions and your ability to alter them will vary widely depending on your hosting arrangements and server software. Here are my server settings based on a self managed Digital Ocean droplet running Ubuntu 16.04 and NGINX.

While your setup might well be different, there are many commonalities that will be appropriate for any hosting environment.

The recommended settings for WordPress directories and files are as follows:

Directories should be set to 750

Files should be set to 640
except wp-config.php which should be 440 or 400.

Set directory permissions

find /srv/www/your-site/ -type d -exec chmod 750 {} \;

Set file permissions

find /srv/www/your-site/ -type f -exec chmod 640 {} \;

Set wp-config.php permission

sudo chmod 440 your-site/wp-config.php

Define the fs method in wp-config.php

define('FS_METHOD', 'direct' );