When you use Trellis for local WordPress development, Xdebug is installed for debugging. This can be very useful. But when you run composer to update plugins, WordPress and so on and use Xdebug composer will become very slow. And you will get this warning
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Chris Loftus wrote about it . He explained how to Disable Xdebug running Composer. He offered a solution to keep on using Xdebug but not while running cli stuff. A solution for setups with Ubuntu and PHP 7. And As we know that is what Trellis uses. So an awesome solution how to disable Xdebug running Composer on Trellis! The solution is to run the following command:
sudo phpdismod -s cli xdebug
This will disable Xdebug for CLI purposes. To quote Chris again:
The -s flag tells it to disable Xdebug for the CLI SAPI (/etc/php/7.0/cli) and not FPM.
And that is what we are looking for. I still want to be able to use Xdebug, but I do want composer to run smoothly and as fast as possible on my local Trellis LEMP server.
Once you have run that command you will no longer get the warning. Composer will be considerably faster from that moment on.
A few months ago – 8 months already yikes! – I wrote a great post on Bedrock Modern WordPress Stack and as is it became a rather long post I decided to indicate I would write on Bedrock Ansible – now Trellis a little later on. Well time has come and gone and the only item I wrote about was dealing with Trellis errors. Also got a lot of hits, but this follow up blog post was still missing. So I finally decided to give it a shot again. WordPress LEMP Stack management with Trellis here we go!
Trellis is basically an extension of Bedrock and helps you with easing the deployment of sites and management of sites locally, on staging and production environments.
Again, just like I love Bedrock Modern WordPress stack I am infatuated with Trellis for local development, provisioning and deployment of WordPress sites. It is an awesome tool built on the shoulders of giants like mainly Ansible for using its playbooks and Vagrant to do several things:
local environment creation with Vagrant, VirtualBox and Ansible
Staging setup using Ansible for staging on subdomain or other local domain
Deployment of site to final destination or production
Trellis Specs 02-2016
And as these awesome guys at Roots keep on developing and updating all tools we can now use HTTPS, HTTP2 and PHP 7 . How awesome is that! Here the latest specs you get setting up a local server (Vagrant Box) or a remote server:
Ubuntu 14.04 Trusty LTS
Nginx (with optional FastCGI micro-caching)
MariaDB as a drop-in MySQL replacement (but better)
I assume you noticed NGINX. A lot of devs out there are still using Apache and I am still too, but Nginx is awesome and really is the future for dealing with more traffic and is being used more and more so this should not slow you down one bit.
Setting up Trellis
Basically the whole setup has been explained on the Trellis repo and I think it is pretty clear. It has been written with using Bedrock in mind. But if you do not want to use the neat Bedrock file structure you do not have. The same things goes for Trellis. If you want Sage and Bedrock only or just Sage you are free to do so.
Most local boxes do not have Ansible installed nor all the Vagrant tools for that matter. So double check what you have before you start of with Trellis. These tools are needed. Git is also needed. This for keeping track of changes in the main repo, your local installation and on staging as well as the pleasure of simply cloning the Trellis repo.
After you made sure you installed VirtualBox, Vagrant and needed plugins as well as Ansible it is time to clone Trellis and get started setting up the local Vagrant box.
git clone https://github.com/roots/trellis.git
Then you need to install all Ansible roles and packages:
ansible-galaxy install -r requirements.yml
Well and then you have the opportunity to add Bedrock to the mix if you want to and then I would refer to the earlier article. If you are doing a new site setup from scratch I would. If not I would clone the whole package once the server has been set up locally and or remotely. But really even then you could do the Bedrock setup and import the database and needed files for your app.
Here are the command to set up Bedrock inside folder demo.dev (changed to site later as this makes more sense workflow wise)
git clone https://github.com/roots/bedrock.git site
You should now have your project folder with inside the folder / directory trellis and the directory with the name of you site. I chose demo.dev in some of the screenshots, but for you it would make more sense to use use site as the config files have been setup that way and as the root folder already could or should have the name of your project, namely the production site domain name.
Configuration – Local, Staging and Production
What is next is configuring all the necessary files to make the local, staging and production setup correct with correct domain names, admin user and password, MySQL password and so on. We will configure the files for development for now. The process is almost the same for staging and production. The main files to configure are located in project-name > trellis > group_vars > and then for the purposes of this blog post development:
The two files we will adjust here are wordpress_sites.yml and vault.yml . Here we indicate the site domain name locally and what MySQL password and WordPress user and password we want to be created.
The file wordpress_sites.yml is the main file where you pick the basic elements for you development environment. In this case the local environment. Here below you see I have the name test1.com as main domain, test1.dev for development and local path site (unchanged). I also added the home url and site url as well as database user and name.
# Documentation: https://roots.io/trellis/docs/local-development-setup/
local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
site_title: test1 Site
# admin_password: (defined in group_vars/development/vault.yml)
initial_permalink_structure: /%postname%/ # applied only at time of WP install and when `site_install: true`
# db_password: (defined in group_vars/development/vault.yml)
vault.yml content for local development is not adjusted much as all is for local development. I kept the MySQL password as is and only adjusted the domain name and admin password.
with that done we can start generating our own local development environment by starting up our Vagrant box. This will contain all specified by Trellis and have a WordPress site with Bedrock’s structure up and running. Go to the trellis folder and fire of:
Vagrant Provisioning snapshot:
Once that is done the site will be up and running in your browser. In my case a test1.dev and you will see something like:
So there you go. The magical has happened. A local LEMP stack has been setup by Trellis with a secure site structure using Bedrock and a WordPress site up and running. Isn’t this awesome! You can start working on your theme now or plugins and when you are ready to move to staging you can configure all the other files. That should be a breeze.
As this post is again really long I will add deployment to production to another post. I might even split this one into two posts again some time later on. Stay tuned!
I have been working on and off as a web developer and mainly with WordPress for over 15 years. I worked with different frameworks such as Genesis, Thesis, Canvas and Divi. I also worked or dabbled in a few starters themes such as _s . And often I have customized themes that customers found / bought on Themeforest. And as these options became less and less appealing to me I started to look for something else. That choice has become Roots
Reasons why I am moving
The reasons why I am moving more and more of my projects to Roots with Bedrock as a modern WordPress stack, Ansible for provisioning and Sage as a starts theme are many. Allow me to go throught the most important ones.
To learn a new theme every time a client decides this is the theme for him or her is tiresome, tedious and NOT efficient. It will require you to read new documentation, get familiar with different theme panels and coding techniques used by the developer in question.
Most of the time these starter themes or frameworks had something I liked, but they were always lacking something or were not rigid enough in the way they were set up to truly offer clients high end themes and get them these in the quickest way possible.
When you create your own code, or know a starter theme inside out you can provide your own support. When you use a theme that is supported by WordPress experts you have people to fall back too. Roots is such a warm and fuzzy place.
Roots to the rescue
When you create a product for a client don’t do something half-assed. Deliver quality and know your product. Good quality products attract good quality clients. And that is something we all want right?
Modern WordPress Development with Roots to the rescue! Roots is a all encompassing framework. Not a WordPress framework, but a place where people help you build better WordPress sites, become a better programmer and build sites faster. This by providing you with a Modern WordPress Stack: Bedrock, efficient provisioning system with Ansible and a kick ass starters theme called Sage.
This does not mean this will be easy. Learning a new work structure takes time, but believe me this is worth it. I am only a beginner, but I have been convinced and as a new enthusiast I will do my best to bring you over to the dark side too 😉
Modern WordPress Development with Roots
So what is modern WordPress Development with Roots? Well it is a package that helps you set up your local, staging and production environments, put together a modern WordPress Stack AND provides you with a very effcient WordPress Starters Theme to deliver awesome WordPress sites your clients will love!
• Bedrock Modern WordPress Stack- Better folder structure, Dependency management with Composer, Easy WordPress configuration with environment specific files, Environment variables with Dotenv, …
• Bedrock-Ansible – Easy server provisioning with Ansible (Ubuntu 14.04, PHP 5.6 or HHVM, MariaDB), Local Vagrant Package, One-command deploys, WP CLI,..
• Sage Starters Theme – Roots Starters Theme managed with NPM asset builder, Bower for front end package management, Gulp for image optimization, concatenationan and minification and sass/less compiling and error checking, Browser Synch.
See next post(s) with more details on Bedrock, Bedrock Ansible and Sage: