Setting Up and Configuring Bedrock in ServBay Environment
What is Bedrock?
Bedrock is a modern WordPress project structure that utilizes Composer to manage dependencies, offering better project organization and development experience. It makes WordPress development and deployment simpler, more efficient, and secure.
Steps to Install Bedrock
In this article, we will explain how to install and configure Bedrock in the ServBay environment.
Step 1: Create Project Directory
First, create a new project directory in the www
directory of ServBay:
cd /Applications/ServBay/www
mkdir servbay-bedrock-app
cd servbay-bedrock-app
2
3
Step 2: Create Bedrock Project Using Composer
Since ServBay comes with Composer pre-installed, we can use Composer to create the Bedrock project directly:
composer create-project roots/bedrock .
Step 3: Create Database and User
Access ServBay's built-in phpMyAdmin tool
Open https://servbay.host/, click on "phpMyAdmin", and enter the phpMyAdmin tool.
Create Database User
Navigate to the User Accounts Page
- On the main page of phpMyAdmin, click on the "User Accounts" tab in the top menu.
Add New User
- Click "Add user account".
- Fill in the following information:
- Username:
bedrock_user
- Hostname:
localhost
- Password: enter a secure password, e.g.,
password123
- Re-type: re-enter the password
- Username:
- In the "Database for user" section, select "Create database with same name and grant all privileges".
- Ensure to check "Grant all privileges".
- Click the "Go" button.
Step 4: Configure Bedrock
Edit Environment Configuration File
In the project root directory, copy
.env.example
to.env
:bashcp .env.example .env
1Edit
.env
FileOpen the
.env
file with a text editor and configure the database connection info and other necessary settings:DB_NAME='bedrock_user' # same as username DB_USER='bedrock_user' DB_PASSWORD='password123' DB_HOST='localhost'
1
2
3
4You can also configure other settings in the
.env
file likeWP_ENV
,WP_HOME
, andWP_SITEURL
:WP_ENV='development' WP_HOME='http://servbay-bedrock.local' WP_SITEURL='${WP_HOME}/wp'
1
2
3
Step 5: Configure Web Server
Add New Site
Open ServBay, click on the "Hosts" tab, and add a new site:
- Name:
My Bedrock Site
- Domain:
servbay-bedrock.local
- Site Type:
PHP
- PHP Version: Choose the appropriate PHP version
- Document Root:
/Applications/ServBay/www/servbay-bedrock-app/web
- Name:
Save Configuration
Save the configuration.
Step 6: Complete Installation
Access Installation Page
Open your browser and go to
https://servbay-bedrock.local/wp
, and you will see the WordPress installation page.Fill in Database Information
Complete the database connection info as prompted:
- Database Name:
bedrock_user
(same as username) - Username:
bedrock_user
- Password:
password123
- Database Host:
localhost
- Table Prefix:
wp_
(can be changed as needed)
- Database Name:
Fill in Site Information
Complete the site info as prompted, including site title, admin username, and password.
Complete Installation
Click the "Install WordPress" button to finish the installation process.
Step 7: Install Themes and Plugins
Install Theme
Log in to the WordPress admin dashboard, click "Appearance" -> "Themes", and choose and install a theme you like.
Install Plugins
Click "Plugins" -> "Add New", search and install the plugins you need, such as SEO plugins, security plugins, etc.
Using Bedrock to Build Website
Now that you have successfully installed and configured Bedrock in the ServBay environment, you can start using it to build your website. Here are some common tasks:
Create Pages and Posts
Create Page
In the WordPress admin dashboard, click "Pages" -> "Add New", fill in the page title and content, then click "Publish".
Create Post
Click "Posts" -> "Add New", fill in the post title and content, choose categories and tags, then click "Publish".
Configure Navigation Menu
Create Navigation Menu
Click "Appearance" -> "Menus", and create a new navigation menu.
Add Menu Items
Add pages, posts, categories, etc., to the navigation menu, and then click "Save Menu".
Customize Widgets
Add Widgets
Click "Appearance" -> "Widgets", and drag the widgets you need to the sidebar or other widget areas.
Configure Widgets
Configure the widget settings as needed, and then click "Save".
By following these steps, you have successfully installed and configured Bedrock in the ServBay environment and started using it to build your website. Bedrock's modern project structure and powerful features make it an ideal choice for building various types of websites.