I’ve been exploring how to use WordPress for development and what’s possible in terms of operations.
While researching WordPress deployment methods, I stumbled across the term “Bedrock.”
It sounded promising, so I decided to set it up, run it locally, and see how it works in practice.
When I first Googled “Bedrock,” I found this:
Minecraft Bedrock Edition is a version of Minecraft that supports multiple platforms.
Hmm. So you can run WordPress on Minecraft? Guess I’d better start studying Minecraft first...
(just kidding)
The explanation was as follows.
In WordPress, Bedrock refers to a boilerplate that improves the standard WordPress folder structure while leveraging Composer (a dependency management tool) and environment variables to streamline development and enhance security.
Here’s the official site: https://roots.io/bedrock/
Let’s dive in and see what Bedrock actually offers.
Benefits of Bedrock
How is Bedrock different from the traditional WordPress setup?
- Cleaner, more manageable folder structure
- WordPress core is listed as a dependency
- Environment variables are supported
Traditionally, WordPress developers have mainly worked inside the wp-content directory. As long as you adjusted wp-content, you could usually get by.
Bedrock, however, is designed so you can focus exclusively on wp-content, while keeping the rest managed by Composer.
By defining WordPress core as a dependency, you also eliminate unnecessary files when managing projects with GitHub.
And with environment variables, the values you’d typically hardcode in wp-config.php can instead be handled securely in a .env file.
Bedrock Project Structure
公式サイトAccording to the official docs, Bedrock uses the following layout:
├── composer.json
├── config
│ ├── application.php # Primary wp-config
│ └── environments
│ ├── development.php
│ ├── staging.php
│ └── production.php
├── vendor # Composer dependencies
└── web # Public document root
├── app # WordPress content dir
│ ├── mu-plugins
│ ├── plugins
│ ├── themes
│ └── uploads
├── wp-config.php
├── index.php
└── wp # WordPress core
At the top level is composer.json, indicating that Bedrock relies on Composer.
Composer is a dependency manager for PHP projects that automatically handles external libraries and packages.
In Bedrock, WordPress core itself is installed via Composer, so you don’t need to manage it manually.
The web/app directory corresponds to the traditional wp-content folder.
Creating and Running a Bedrock Project Locally
Step 1: Create the Project
Run the following command:
composer create-project roots/bedrock
This assumes the composer command is available. If you get a “command not found” error, install Composer first.
Once the command finishes, a bedrock folder is created.

Step 2: Running in a Local Environment
I typically use Local (by Flywheel) for local WordPress development. In Local, click Site folder to open the project directory.

Note: Any local dev environment that can run WordPress is fine, but you’ll need to configure the web server properly for Bedrock.
Move the bedrock folder into the site’s directory structure.
app

Place the created Bedrock folder.

Step 3: Configure Environment Variables
Inside the bedrock folder, you’ll find .env.example.
Copy it and rename it to .env.

Go up one level.

Copy it and rename it to .env.

For example, here’s my .env file:
DB_NAME='local'
DB_USER='root'
DB_PASSWORD='root'
WP_ENV='development'
WP_HOME='http://bedrockexample.local' # input Site domain
WP_SITEURL="${WP_HOME}/wp"
# Generate your keys here: https://roots.io/salts.html
AUTH_KEY=')}Ikk%1aB$0Xt-)/K_?I%1&DB`_004uJi@X4@rUZ}0&v@FeW%`|rMR1ZWWVYNlus'
SECURE_AUTH_KEY='(52*Xa=v,V<1WGmY5|U9JV&O3o7f-blyXIxeDKY%GxH]??jJ-AzS,dKBZ=-Z!|Od'
LOGGED_IN_KEY='zOTN[->y7RJ*1!!qA3:Th2PO;o(<g(:cC4oD-0:4tvgiIP5$g;h-jQ+zI#{}%OfX'
NONCE_KEY='aadmYm1_f<_@wVW&J-.1U6gVt<.a1y19m}j9$>Q;EYyK&Gt[>Z<&?:dE0WJ41m3+'
AUTH_SALT='TL/_&Gs4t3;6oG:9X#h;^H1ENWh;;JsdaD7ku,{D>zf[h#{zq4Bt3C#o->UXJ!zH'
SECURE_AUTH_SALT='ew/1p7]3zBg]^mW}$}O$4ju0V&uVsazy*0loh>M%KNu=|O1JbFWI$N;z%3NhoahR'
LOGGED_IN_SALT='k&hT3.nim6.Pz#(hVws>xI;GJ]}4FX7Se0VX609}l*duDrc&@m9sv[LMuep,X4AI'
NONCE_SALT=')B*9iZ$x@(v*_?X,x*2Y/zJuge<WP%ix$5c2hUF`iTBFkRnX!#Vb>w|W9b1U(aJc'
For the keys and salts, you can auto-generate values here: https://roots.io/salts.html .
Step 4: Adjust Nginx Config
In Local, open:

Go to conf.

Go to nginx.

Open site.conf.hbs.

Locate the root directive and change it to:

Restart the site.

Setup complete.
Step 5: Verify Setup
Click Open site in Local.

If everything is configured properly, you should see WordPress load.

To log in to the admin dashboard, go to:
http://your-domain/wp/wp-login.php

To confirm Bedrock is running, try adding a test theme.

To be sure, add a new theme called test-theme and confirm that Bedrock WordPress is running instead of the default WordPress.

Bedrock is now running locally.
Summary
After some trial and error, I managed to get Bedrock running locally.
At this stage, I haven’t fully experienced its benefits, but I expect they’ll become clear during real-world operations and deployment.
I plan to continue experimenting—deploying to a server, building themes, and writing follow-up posts.
Common Errors Encountered
404 Not Found

A 404 Not Found error appears when the site’s index.php cannot be found.
Check the root setting in the site.conf.hbs file to ensure it is correct.
In my case, my Windows username started with the letter “t”. As a result, the root setting looked like this:
root "C:\Users\txxxx\Local Sites\bedrockexample\app\bedrock\web";
となっていました。
At first glance, this seemed fine, but when I checked logs/nginx/error.log, I found the issue. logs/nginx/error.log
を確認したところ、下記のようなログが出力されていました。

Looking closely, the path showed up as \Users xxxx\. The sequence “\t” was interpreted as a TAB character, which broke the path.
The fix was to escape the path properly, like this:
root "C:\Users\\txxxx\Local Sites\bedrockexample\app\bedrock\web";
502 Error

A 502 Request Error appeared when the site.conf.hbs file contained incorrect syntax after I edited it.
For example, it happened when the final semicolon (;) was missing. It can also occur if there are other syntax mistakes in the configuration file.

Warning: mysqli_real_connect(): (HY000/1045): Access denied……
The following error appeared in the browser.
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'xxx'@'localhost' (using password: YES) in C:\Users\xxx\Local Sites\bedrockexample\app\bedrock\web\wp\wp-includes\class-wpdb.php on line 1988
This error means the database could not be accessed, caused by incorrect values in the .env file.
.env
Double-check the contents of your .env file.
When I opened the page, the stylesheet wasn’t applied.

Somehow Bedrock’s CSS wasn’t loading correctly.
Use developer tools to confirm whether the stylesheet is being loaded.

In my case, it was trying to load from: http://localhost/wp/wp-includes/js/...
The cause was that WP_HOME in the .env file was set to “localhost.”
WP_HOME
Update WP_HOME to use your site’s domain instead.
Comments