Bedrock WordPress is a set of files and folders that provide a standard structure and configuration for a project. It is designed to make WordPress development easier, more secure, and more reliable by following the best practices of modern web development.

You can think of Bedrock WordPress as an IKEA kit.

An IKEA kit is a package of pre-cut materials and instructions that allow you to build your own project without worrying about measuring, cutting, or finding the right materials – you just follow the instructions and assemble the pieces.

Similarly, Bedrock WordPress makes it easier to build a WordPress website because you don’t have to worry about installing, updating, or configuring WordPress or its plugins. You just follow the documentation and use the tools that Bedrock provides.

Why Use Bedrock?

Here are some of the benefits of using Bedrock:

  • Better folder structure: Bedrock separates the WordPress core files from the custom content and configuration files. This makes it easier to update WordPress and keep track of your changes. It also limits access to non-public files for enhanced security.
  • Dependency management with Composer: Bedrock uses Composer (a PHP dependency manager) to manage your WordPress installation and plugins. This means you can easily install, update, and remove plugins with a single command. You can also use Composer to install plugins from other sources, such as GitHub or Packagist.
  • Easy WordPress configuration with environment specific files: Bedrock uses Dotenv to manage environment specific configuration. This means you can have different settings (such as database credentials, debug modes, or caching options) for development, staging, and production environments. 
  • Autoloader for mu-plugins: Bedrock has an autoloader for mu-plugins (must-use plugins). This means you can use regular plugins as mu-plugins by simply placing them in the app/mu-plugins directory. Mu-plugins are loaded before regular plugins and cannot be deactivated by users. This is useful for plugins that provide essential functionality or security features.

As you can see, Bedrock is a great way to improve your WordPress development workflow and create more professional and secure websites. However, it is not the right choice for everyone.

Who Should Not Use Bedrock?

Bedrock WordPress makes development easier, but it’s definitely not for everyone. Here are some reasons why you might not want to use Bedrock WordPress:

  • You are not comfortable with using the command line: Bedrock WordPress requires you to use the command line to install and update WordPress and its plugins with Composer – a PHP dependency manager.

    If you prefer to use a graphical user interface (GUI), Bedrock WordPress might not be for you and you should stick to RunCloud’s default WordPress installation.
  • You are not familiar with Git or version control: Bedrock WordPress is designed to work well with Git, a version control system that allows you to track and manage changes to your code. If you don’t know how to use Git or don’t want to use version control for your project, you won’t be able to take complete advantage of Bedrock WordPress.
  • You are using a shared hosting provider that does not support Bedrock WordPress: Bedrock WordPress has some specific requirements for hosting, such as SSH access, Composer support, and custom document root. If you are using a shared hosting provider that does not meet these requirements, or doesn’t allow you to customize them, Bedrock WordPress might not be for you. 

    At RunCloud, we don’t provide any servers. You bring your own servers – so these restrictions don’t apply to RunCloud users. 
  • You are happy with the standard WordPress structure and configuration: Bedrock WordPress changes the default WordPress structure and configuration to make it more organized and secure. For example, it separates the WordPress core files from the custom content and configuration files, and it uses environment variables to store sensitive information. If you are happy with the standard WordPress structure and configuration and don’t want to change them, Bedrock WordPress might not be for you.

Bedrock WordPress is a great tool for WordPress developers who want to improve their workflow and create more professional and secure websites. However, it’s not a one-size-fits-all solution. Before you decide to use Bedrock WordPress, make sure you understand its benefits and drawbacks, and whether it suits your needs and preferences.

How To Install Bedrock on RunCloud

If you would like to use Bedrock WordPress on your RunCloud server, you can do so easily. 

Creating An Empty Web App

Start by creating an empty web application by going to the RunCloud dashboard and clicking on “New Application”. Open the “Empty Web App” tab and provide a suitable name for your application. This name will not be visible to visitors – it will only be used to identify your website on RunCloud dashboard.

Next, pick an existing system user if you like – but it’s a good idea to create a new user for each application as this provides better security. To do so, simply uncheck the box and enter the name that you would like to use for the new system user profile. RunCloud will automatically create a new profile and grant necessary permissions during installation.

After this, you’ll need to configure your domain name and SSL/TLS settings. You can either use the provided test domain, or configure your own domain name.

You can also set up automatic backups if you like. Refer to our in-depth knowledge base articles on SSL/ TLS certificates and Updating A Web Application’s Domain to learn how to do this.

Finally, you’ll need to configure the web server settings of your application. Bedrock serves files from /web directory, so make sure to add it to your public path.

Next, change the PHP version to one of the supported versions; at the time of writing, Bedrock supports only PHP 8 and newer.

After you have configured all the settings, click on ‘Deploy’ to publish your empty web application.

Installing Bedrock WordPress

As we mentioned earlier, you’ll need to be comfortable with CLI to work with Bedrock. Start by logging in to your server via SSH – make sure to log in using the system user that is the owner of the application. If you logged in as a different user, you can switch user using the following command:

sudo su <name-of-system-user>

Once you’ve successfully logged in, you’ll need to navigate to the root directory of your web application. You can do this by using cd <path> command, where <path> is the root path as shown in the RunCloud dashboard.

In the given directory, you can execute the ls command to view the contents of this directory. This should only show you a folder named “web” – if you get a different output, you’re in the wrong directory.

Once you are sure that you are in the correct working directory, you can execute the following commands to delete everything in the current directory and install Bedrock in the current directory:  

rm -rf ./*

composer create-project roots/bedrock

The above commands show an output similar to the following screenshot:

After the installation is complete, you can run the following command to view the contents of the current folder. 

ls -lah

The above command will show an output similar to the following screenshot:

Configuring BedRock WordPress

After installation, you’ll need to configure the .env file. Bedrock provides an empty .env file that you can edit directly as well as an .env.example file that contains another copy of an empty .env file that you can use in case you mess things up.

To do this, you can either use a CLI based editor such as nano, or use RunCloud’s GUI based File Manager. To use this simply go to the RunCloud dashboard, click on the “File Manager” in the left menu and click on .env to edit it.

Creating The Database

First, you’ll need to create a new database and a database user for your application. You do this easily from the RunCloud dashboard by navigating to the Databases tab. If you need step-by-step instructions, you can refer to our Knowledge Base article on Creating a Database for Your Web Application.

Once you have created a new database user and granted it the necessary access to a database, you can add these credentials to your .env file. At this stage, your .env file should look like this:

Optionally you can also edit the DB_PREFIX variable to change the prefix used for your WordPress tables.

Changing The Environment

After adding the database credentials, change the WP_ENV variable. If you are using it in a production environment, you should set this to production.

Next, add the base URL of your site – you can easily find this in your RunCloud dashboard.

While adding the URL, make sure to remove the trailing / or your site will use two slashes. Optionally, you can edit line 15 to change the WordPress dashboard URL. Just replace /wp with your desired path. For instance:

WP_SITEURL="${WP_HOME}/wp"

WP_SITEURL="${WP_HOME}/secret_path"

Add WordPress Salts

Finally, you’ll need to add WordPress salts. Salts are strings of alphanumeric characters that improve the security of your web applications.

The easiest way to generate salts is by using a WordPress Salts generator. This is a simple service that generates new salts every time the page is refreshed. Copy all the salts on the web page under “ENV FORMAT” and paste them in your .env file, and then make sure you save it carefully. At this point, your file should look like this:

Note: The salts are used to both encrypt and decrypt information; as such, they should be kept secret.

Set Up An Admin Account

Once you have configured and saved the .env file, you can then visit your WordPress site and configure the admin account. After setting up the credentials, you can log into the WordPress dashboard and continue using it normally.