Black Friday Sale: 50% off all plans!
Use code BLACKFRIDAY50

Header

Getting Started with Bedrock and DeployHQ: A Comprehensive Guide

Introduction

Bedrock is a modern WordPress stack that enhances the development workflow by improving folder structure, security, and dependency management. DeployHQ is a powerful deployment service that simplifies the process of deploying web applications. This guide will walk you through setting up a project using Bedrock and deploying it with DeployHQ.

Setting up Bedrock

1. Install Composer

Bedrock uses Composer for dependency management. If you haven't installed Composer yet, follow the installation instructions on the official Composer website.

2. Create a New Bedrock Project

Open your terminal and run the following command to create a new Bedrock project:

composer create-project roots/bedrock your-project-name

This command will create a new directory with your project name and install all necessary dependencies.

3. Configure Environment Variables

Bedrock uses environment variables to manage configuration. Navigate to your project directory and rename the .env.example file to .env:

cd your-project-name
mv .env.example .env

Now, open the .env file in your preferred text editor and update the following variables:

DB_NAME=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_password

WP_ENV=development
WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp

AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'

Replace the placeholder values with your actual database credentials and site URL. For the salts, you can generate secure values using the WordPress Salt Generator.

4. Install WordPress Core and Plugins

Run the following command to install WordPress core and any additional plugins specified in your composer.json:

composer install

5. Set Up Local Development Environment

Configure your local development environment to point to the web directory as the document root. This directory contains the WordPress core files and your theme.

Configuring DeployHQ

1. Create a DeployHQ Account

If you haven't already, sign up for a DeployHQ account at https://www.deployhq.com/.

2. Create a New Project

  1. Log in to your DeployHQ account and click "New Project."
  2. Choose your repository type (GitHub, Bitbucket, GitLab, etc.) and follow the prompts to connect your repository.
  3. Give your project a name and click "Create Project."

3. Configure Server Details

  1. In your project dashboard, go to "Servers" and click "New Server."
  2. Choose your server type (e.g., SFTP, SSH/SCP).
  3. Enter your server details, including hostname, username, and authentication method (password or SSH key).
  4. Specify the remote path where your files should be deployed.
  5. Click "Create Server" to save your configuration.

4. Set Up Deployment Configuration

  1. Go to "Configuration" in your project settings.
  2. Under "Build Commands," add the following to install Composer dependencies:
composer install --no-dev --optimize-autoloader
  1. In the "Exclusions" section, add files and directories that shouldn't be deployed, such as:
/.git
/.env
/vendor
/web/app/uploads
  1. Under "Excluded Files" add your .env file to ensure it's not overwritten during deployment:
.env

5. Configure Environment Variables

  1. Go to "Config Files"
  2. Create a new config file named .env.
  3. Add your environment variables, similar to your local .env file, but with production values.

6. Set Up Automatic Deployments (Optional)

  1. Go to "Automatic Deployments" in your project settings.
  2. Choose the branch you want to automatically deploy (e.g., main or production).
  3. Select the server to deploy to and any additional options.
  4. Click "Create Automatic Deployment" to enable this feature.

Usage and Benefits

Bedrock organizes WordPress in a more structured and secure way:

  • It separates WordPress core files from your content, making updates easier.
  • Uses Composer for dependency management, allowing easy installation and updates of plugins and themes.
  • Improves security by moving sensitive configuration out of the web root.
  • Encourages better development practices with its modern stack approach.

DeployHQ streamlines the deployment process:

  • Automates deployments, reducing human error and saving time.
  • Provides a clear history of all deployments, making it easy to track changes and roll back if necessary.
  • Offers the flexibility to customize the deployment process with build commands and file exclusions.
  • Simplifies management of multiple environments (staging, production, etc.).

By combining Bedrock and DeployHQ, you create a robust development and deployment workflow for WordPress projects. This setup enhances productivity, maintainability, and security, allowing you to focus on building great websites rather than managing infrastructure.

Remember to always test your deployments in a staging environment before pushing to production. Happy coding!

Tree

Proudly powered by Katapult. Running on 100% renewable energy.