WordPress
Article

Using Chassis for WordPress Development

By Aleksander Koko

When I wrote the first article on WordPress and Vagrant I introduced WordPress VVV. VVV is a Vagrant configuration for developing WordPress themes and contributing to the core. One common problem, however, is that many people were overwhelmed with VVV. Especially those new to Vagrant, who just wanted to get something simple up and running fast. There are many other Vagrant configurations, one of the easiest to use and most popular in WordPress circles is Chassis.

Chassis for WordPress Development

Chassis is a simple Vagrant configuration, popular among WordPress plugin and theme developers. It’s easy to get started with and use on a per project development. In this article I’ll walk you through setting up Chassis. The folder structure is a bit different, so we’ll get into that too. The Chassis configuration has a hierarchy, so understanding how that works is also important. The last topic we’ll cover is extending Chassis by adding plugins that include more features.

Why Use Chassis?

There are several reasons why someone would choose to use Chassis for WordPress development. Firstly, Chassis is lightweight. In contrast, VVV is rather heavy as it comes with a wide range of tools. The problem with VVV is that it can take a long time to install, and it’s slow. In comparison, Chassis takes just a couple of minutes to install.

Chassis is so lightweight, that it only comes with:

  • WordPress 4.0
  • PHP 5.4 (includes the cURL and GD extensions)
  • Nginx
  • MySQL

Where is phpMyAdmin? Everything else that you may want to install, such as phpMyAdmin for example, comes as an extension. Memcache is also available, Xdebug is comming soon.

The installation is easy and the Chassis documentation covers it very well. You need to install the latest version of Vagrant and VirtualBox. However, Chassis requires an additional tool to work with the network. You can choose either Bonjour or Avahi. If you’re on Mac then you will already have Bonjour pre-installed. If you’re on Windows you can install Bonjour via iTunes. If you use Linux then you’ll have to install Avahi by executing:

[shell]
sudo apt-get install avahi-dnsconfd
[/shell]

Installing Chassis

You can get a copy of Chassis from the GitHub repo, just execute:

[shell]
git clone http://github.com/Chassis/Chassis.git chassis
cd chassis
git submodule update –init
[/shell]

The command git submodule update --init makes sure you download every submodule.

Installing Supercharger

A nice feature of Chassis is the separation of the WordPress and development directories. By default the folder that contains the themes, plugins and uploads folder is the content folder. When you first clone the repository, there is no content folder. The WordPress folder is called wp but there is no content folder. You can start creating the folder yourself and build the structure. The team behind Chassis has a predefined content folder available on GitHub (called ‘Supercharger’). Supercharger comes with some plugins, such as WordPress SEO, WordPress Importer, Limit Login Attempts and the Regenerate Thumbnails plugin.

[shell]
git clone https://github.com/Chassis/Supercharger.git content
cd content
git submodule update –init
[/shell]

To get up and running, you only need to vagrant up and everything will be installed. Chassis uses a ‘precise64’ box by default. The first time you vagrant up the project the box will be downloaded if no other Vagrant configuration has used it before. To do this, navigate to the root of the project and then execute:

[shell]
vagrant up
[/shell]

Wait until the installation finishes. You now have a ready to use environment. Everything is pre-configured, there’s no need for the famous 5 minutes configuration. After the installation finishes, visit http://vagrant.local/ in your browser and see if it works. You should see a ready to use WordPress site, skipping the installation process.

You may have noticed that after installation there are two new files. The local-config-db.php file and local-config-extensions.php. Don’t edit these files. They’re generated using the config.yaml configuration. If you want to edit these files, you’ll need to edit config.yaml and then provision using vagrant provision.

Folder Structure and the Configuration Hierarchy

Chassis separates the WordPress folder from the content folder. By default, Chassis disables the auto-update so you’ll have to install any updates manually. Separating the folders is a good decision. Using this separate content folder doesn’t mean that you can’t work with the wp-content folder, but it’s better to stick with the content folder.

config.yaml has a hierarchy. config.local.yaml has the highest priority then config.yaml in the content folder. By default these configuration files don’t come with Supercharger. You can copy the existing file from the root folder of the project. config.yaml and config.local.yaml in the root folder of the project have the least priority. config.local.yaml always has the highest priority in the particular folder.

When you start with a fresh folder you’ll only have one config.yaml in the root folder. This is the lowest priority. Inside that file you can configure the PHP version (5.4 by default), the WordPress directory (/wp by default), the database configuration and WordPress credentials.

Let’s experiment a little. First open vagrant.local/phpinfo.php to see what PHP version you’re using. By default you start with 5.4. Copy the config.yaml to the content folder. Edit the PHP version and set it to 5.5. Execute vagrant provision and after the provision navigate again to vagrant.local/phpinfo.php.

PHP version 5.5 with Chassis

Copy the config.yaml from the content folder and rename the copy you just created to config.local.yaml. Again, edit the PHP version to 5.4 again. Execute vagrant provision and test it in your browser.

PHP version 5.4 with Chassis

Try the same thing with the admin configuration. On config.local.yaml edit the password to “thepassword”. Execute vagrant provision again and test it to login in with this password on the dashboard. The password is wrong. So why is that? You can’t change the password or the admin credentials via provision. However, if you vagrant destroy and vagrant up again, you will see that the password for the admin is now “thepassword”.

Be careful with this configuration. Try to separate the local configuration from the deployment configuration.

Plugins for Chassis

Chassis supports extensions, I’ll cover a few of the popular ones.

MailCatcher
As you can see from the name and icon, this is a tool that catches emails that are sent to it and displays those in a web interface. This tool is used for testing purposes, when you don’t want emails sent to a real email provider, but you also need to see if it works. Installing this tool using Chassis is easy so you don’t have to worry about configuring anything.

[shell]
cd extensions
git clone https://github.com/Chassis/mailcatcher.git mailcatcher
cd mailcatcher
git submodule update –init
cd ../..
vagrant provision
[/shell]

Copy the Mailcatcher repository on Chassis to the extensions folder and then vagrant provision. Now go and add a comment to a post. Navigate to http://vagrant.local:1080/ and you will see that mailcatcher has ‘caught’ the email.

Chassis and the mailcatcher extension

phpMyAdmin
I don’t think that this tool needs any introduction. This is one of the most popular tools when dealing with databases. Just like MailCatcher, this extension doesn’t need any configuration at your end. The installation is similar to MailCatcher.

[shell]
cd extensions
git clone https://github.com/Chassis/phpMyAdmin.git phpmyadmin
cd ..
vagrant provision
[/shell]

Now navigate to vagrant.local/phpmyadmin and you’ll see that no login is required.

Memcache
When you’re developing a website with WordPress, you don’t know for sure how much traffic the website is going to get. High volumes of traffic is a nice thing, but have you thought about how you’re going to handle it? It’s possible that your server will crash from the huge amount of requests, or in the best case scenario your site will become slow. This is where caching comes in. This is the definition of Wikipedia for Memcached:

Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.

The Memcache extension installs Memcached properly, you can read the documentation for information on how to use this extension.

Conclusion

Using Vagrant and Chassis is one of the easiest to use and fastest environments for WordPress development. It has a good workflow by separating the WordPress installation from the working folder. It’s also simple, yet powerful when it comes to extensions.

  • http://cozmotek.com cozmo technology

    Good post! I never heard of Chassis before and this article was very informative.

    • Aleksander Koko

      Thanks @cozmotechnology:disqus . Much appreciated :)

  • gregraven

    Sounds about ten times more difficult than using Bitnami Stack for WordPress.

    • Aleksander Koko

      Bitnami is a great tool and I have used it a lot but consider using Vagrant. Just try it. I personally have used Bitnami, Mamp, Wamp, Lamp (they are the same) but transited to Chassis as it keeps my system cleaner and now I have a better environment. Not only for WordPress. Also I use when working with vanilla php or frameworks (Laravel mainly).

      There are many reasons why you should try using Vagrant environments. If you don’t like them you can use Bitnami or any tool you like. There is no wrong tool.

      • gregraven

        I’ll check it out. Thanks. I, too, used to use MAMP (MAMP Pro, if that makes a difference), but there seemed to be little support, few updates, and some general crankiness. I now use VirtualHostX for static site development, and Bitnami for WordPress development. The one issue I have with the Bitnami Stack for WordPress 4.0.1 is that you can have only one install on your system — no more having separate instances in each user account. If Chassis / Vagrant could give me that, I might have to switch.

        • Eliot Akira

          You can have multiple installs of WordPress on a Bitnami stack: https://wiki.bitnami.com/Applications/BitNami_Wordpress#How_to_install_several_WordPress_modules_on_the_same_stack.3f The WP module can be found on the MAMP stack page: https://bitnami.com/stack/mamp/modules

          I’m a fan of using Bitnami, as it’s compact and self-contained. Recently I set up their Nginx stack and wrote a bash script that automates a new WP install: create copy of a blank site; search & replace site name in nginx-*.conf; create new DB & user; open site in browser. Now, it’s a single command in the terminal to start a fresh WP site – couldn’t be simpler!

          I’ve been curious to try Vagrant, but was hesitant because of its (perceived) complexity and dependence on a seemingly large application, VirtualBox. After reading this concise and in-depth article on Chassis, I’m persuaded to try it. If anything, it’ll teach me more about server configurations.

      • gregraven

        I’ve tried getting Vagrant to run until I’m blue in the face. Even using Hobo, I can’t make any headway.

        • Aleksander Koko

          Can you try to give a description of the error?

          • gregraven

            Sorry, no. Not at this late date. I was trying to get it to run a couple months ago, and I now don’t remember where the failure point was.

  • http://neurozap.com/ Paul Lukitsch

    I too thought this was a helpful article… But for the life of me, I cannot get Chassis to work…. After cloning the repository (and confirming of course I have vbox, vagrant, and bonjour installed), when I enter “vagrant up” in the git shell, it proceeds fine until I begin to get errors starting with:

    ==> default: Setting up php5-fpm (5.4.37-1+deb.sury.org~precise+1) …
    ==> default: /usr/sbin/invoke-rc.d: 438: /usr/sbin/invoke-rc.d: /etc/init.d/php5
    -fpm: not found
    ==> default: invoke-rc.d: initscript php5-fpm, action “start” failed.
    ==> default: dpkg: error processing php5-fpm (–configure):
    ==> default: subprocess installed post-installation script returned error exit
    status 127

    obviously PHP is not installed for some reason…. I have tried it four times reinstalling everything from scratch…. would love any suggestions!!!

  • cool19

    thanks

  • cool19

    is it possible to manage php projects in chassis?

    • Aleksander Koko

      You can use Homestead instead. A Vagrant box from the creator of Laravel but can be used for any other PHP projects. A good series is coming, WordPress on Docker so stay tuned :)

  • Aleksander Koko

    Hi there. It would be nice if we let us know how Vagrant looks to you. Chassis is very easy to get start with.

  • http://www.scriptedpixels.co.uk Kam Banwait

    How do you take this setup on to a live site? I’ve got an existing wordpress site that I need to make a local copy of. I want to use this setup but seeing how the content/plugins folders are not in the typical wp-contents folder how would you then use this with an existing site and then push it back up to the production area?

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in WordPress, once a week, for free.