Install and Configure Craft CMS in the ServBay Environment
What is Craft CMS?
Craft CMS is a powerful content management system (CMS) that provides flexible content modeling, user management, and plugin extension features. It is renowned for its intuitive user interface and developer-friendly features, making it well-suited for building complex and customized websites.
Steps to Install Craft CMS
In this article, we will introduce how to install and configure Craft CMS in the ServBay environment.
Step 1: Create the Project Directory
First, create a new project directory in ServBay's www
directory:
cd /Applications/ServBay/www
mkdir servbay-craft-app
cd servbay-craft-app
2
3
Step 2: Create a Craft CMS Project using Composer
ServBay already includes Composer, so we can directly use Composer to create a Craft CMS project:
composer create-project craftcms/craft .
Step 3: Create Database and User
Access phpMyAdmin Database Management Tool Provided by ServBay
Open https://servbay.host/, click "phpMyAdmin" to enter the phpMyAdmin database management tool.
Create Database User
Enter the User Accounts Page
- On the main page of phpMyAdmin, click "User Accounts" from the top menu.
Add New User
- Click "Add User Account".
- Fill in the following information:
- Username:
craft_user
- Hostname:
localhost
- Password: Enter a secure password, e.g.,
password123
- Re-enter: Enter the password again
- Username:
- In the "Database for user account" section, select "Create database with the same name and grant all privileges".
- Make sure to check "Grant all privileges".
- Click the "Go" button.
Step 4: Configure Web Server
Add New Website
Open ServBay, click the "Hosts" tab, and add a new website:
- Name:
My Craft Site
- Domain:
servbay-craft.local
- Site Type:
PHP
- PHP Version: Select the appropriate PHP version
- Document Root:
/Applications/ServBay/www/servbay-craft-app/web
- Name:
Save Configuration
Save the configuration.
Step 5: Run Craft CMS Installer
Access Installation Page
Open a browser and visit
https://servbay-craft.local/index.php?p=admin/install
, and you will see the Craft CMS installation page.Fill in Database Information
Fill in the database connection information as prompted on the page:
- Database server:
localhost
- Database name:
craft_user
(same as the username) - Username:
craft_user
- Password:
password123
- Database server:
Fill in Administrator Information
Fill in the administrator username, password, and other information as prompted on the page.
Complete Installation
Click the "Complete Installation" button to finish the installation process.
Step 6: Install Plugins and Templates
Install Plugins
Log in to the Craft CMS admin backend, click "Plugins", and search for and install the plugins you need.
Install Templates
Install and configure templates as needed.
Building a Website with Craft CMS
Now that you have successfully installed and configured Craft CMS in the ServBay environment, you can start using it to build your website. Here are some common operations:
Create Pages and Entries
Create Entries
In the Craft CMS admin backend, click "Entries" -> "New Entry", fill in the entry title and content, and then click "Save".
Create Pages
Create and manage pages in Craft CMS according to your website structure.
Configure Navigation Menus
Create Navigation Menu
In the Craft CMS admin backend, click "Navigation" -> "New Navigation Menu", fill in the menu name and other settings, and then click "Save".
Add Menu Items
Add pages and entries to the navigation menu and then click "Save".
Customize Widgets
Add Widgets
In the Craft CMS admin backend, click "Widgets" -> "New Widget", select the widget type you need, fill in the name and other settings, and then click "Save".
Configure Widgets
Configure the widget settings as needed and then click "Save".
Through the above steps, you have successfully installed and configured Craft CMS in the ServBay environment and started using it to build your website. The powerful features and flexibility of Craft CMS make it an ideal choice for building various types of websites.