What is Bedrock?

Developed by https://roots.io/, Bedrock is a WordPress boilerplate used to help organize your WordPress project, structure configuration files, and manage plugins with Composer. Working as part of a team it has enabled us to maintain a standard structure for all our newly deployed WordPress sites.

The organization of Bedrock is similar to putting WordPress in its own subdirectory but with some improvements, including renaming wp-content/ to app/.

Bedrock uses Composer to manage your WordPress install and plugins.

Installing Bedrock

Create a new folder for you new website, then use composer to install Bedrock by navigating in command line to your newly created website folder

# Create our new website folder
$ sudo mkdir -p /var/www/example.co.uk/public_html

Switch to our newly created folder:

$ cd /var/www/example.co.uk/public_html

Then run the composer install for Bedrock:

# Create a new Bedrock project
$ composer create-project roots/bedrock

That adds all the core files managed by composer. You will need to update the .env variables and enter the correct database connection details.

Copy .env.example to .env and update the variables.

The composer install of bedrock will add a bedrock folder into the root of you website folder, with all the files including a folder called web which you will need to point your vhosts file to. Example: /var/www/example.co.uk/public_html/bedrock/web/

Your vhosts file may look like the following:

<VirtualHost *:80>
ServerName www.example.co.uk
ServerAlias example.co.uk
DocumentRoot /var/www/example.co.uk/public_html/bedrock/web
ErrorLog /var/www/example.co.uk/error.log
CustomLog /var/www/example.co.uk/requests.log combined

<VirtualHost *:80>
ServerName dev.example.co.uk
DocumentRoot /var/www/example.co.uk/dev_html/bedrock/web
ErrorLog /var/www/example.co.uk/dev_error.log
CustomLog /var/www/example.co.uk/dev_requests.log combined

In your browser navigate to the new WordPress site, and install WordPress. That will create all the database structure and your WordPress site will now be usable.

One response to “How to install Bedrock, a WordPress boilerplate

Leave a Reply

Your email address will not be published. Required fields are marked *