Bedrock WordPress stack at Webfaction

You want to use Bedrock to build WordPress websites together with Capistrano for deployment. No problem! Below you will find all the steps that will let you setup the Bedrock WP stack on Webfaction servers.


  1. You have Composer installed locally.
  2. You managed to install Bedrock on your local machine following instructions from the official docs. Here is how it might look like if using the create-project command: composer create-project roots/bedrock your_app
  3. You filled in config variables in the .env file including DB_NAME, DB_USER, DB_PASSWORD, DB_HOST and your website works locally.
  4. Your project is under version control. Webfaction has a detailed tutorial on how to install git and init a repository.

Ok, let’s setup deployment of the website with Capistrano. We are going to setup ‘production’ environment - the setup for ‘staging’ or any other environment will look mostly the same.

  1. Setup a new application for your project at Webfaction. Select PHP as the application category. The app will be created in the ‘webapps’ directory:

  2. Create ‘shared’ directory:

  3. Create .env file inside the ‘shared’ directory with the production config:

  4. We are going to install composer in the ‘~/bin’ directory.

    cd $HOME/bin
    curl -sS | php54

    If you are planning to use composer on the command line take a look at this gist.

  5. Now it’s time to configure Capistrano. Usually I remove all configuration from ‘config/deploy.rb’ and move it to an environment specific file such as 'config/deploy/production.rb':

    # application name and your Webfaction login
    set :application, 'your_app'
    set :login, 'your_login'
    # define stage
    set :stage, :production
    # ask for ssh password
    set :password, ask('Password', 'ssh')
    # server info
    server '999.999.999.999', user: fetch(:login), port: 22, password: fetch(:password), roles: %w{web app db}
    # setup env
    fetch(:default_env).merge!(wp_env: :production)
    # git repo - provide path to a file or an URL
    set :repo_url, "/home/#{fetch(:login)}/webapps/git/repos/#{fetch(:application)}.git"
    # path to composer
    SSHKit.config.command_map[:composer] = "php54 /home/#{fetch(:login)}/bin/composer.phar"
    # define which branch will be used for deployment
    set :branch, :master
    # deploy to
    set :deploy_to, "/home/#{fetch(:login)}/webapps/#{fetch(:application)}"
    # log level
    set :log_level, :info
    # linked files
    set :linked_files, %w{.env}
    set :linked_dirs, %w{web/app/uploads}
  6. Before your first deploy, run bundle exec cap production deploy:check to create the necessary directories/symlinks on the server.

  7. Run the deploy command: bundle exec cap production deploy

  8. Now, if everything works as expected, your application will be deployed to the server.

  9. Last but not least, you will want your application to be served from the ‘~/webapps/your_app/current/web’ directory. To make it work you will have to create a ‘Symbolic link’ application in the Webfaction control panel. Enter the absolute path as the origin of the symlink into the ‘Extra info’ field. Finally, switch to the Websites tab and make sure your website is connected with the newly created ‘Symbolic link’ application.

UPDATE 06.2016

After two years the Roots project is still going strong and now includes Trellis (WordPress LEMP stack), Bedrock (WordPress project boilerplate) and Sage (WordPress starter theme). If you prefer complete ready-made solutions you may want to take a look at Pantheon, a new website management platform that greatly simplifies using Wordpress with Git.

Did you like this post?
Previous post
WebKit automatically adds rounded corners and inset shadows to input elements. You may be tempted to remove the default styling with two prefixed properties...
Next post

This year I had an opportunity to visit UX Poland conference and I was blown away by the positive vibe of the event in the beautiful venue of Jablkowski Brothers Department Store in Warsaw.