Now that baserCMS5 has been released, we will install it in a Linux environment. In that case, you may need to install Windows version of git, etc. You can also build a Linux environment by preparing WSL, which is a Windows feature.
https://baserproject.github.io/5/introduce/build_local_env
We will proceed by referring to the installation instructions on the official page. we will work by connecting to a linux instance created in OracleCloud. since we were able to build a production environment in OracleCloud, we will be able to install in AWS, Google Cloud, and Azure as well.
First, create a clone of baserCMS
git clone https://github.com/baserproject/basercms.git
Go to the directory you created and check the files, there is a directory with docker related files.
cd basercms
cd docker
Check the contents of docker-compose.yml.default to see which image is being used. The description was as follows
version: '3'
# volumes:
# db-volume: # Uncomment this line for Windows
services:
bc-db:
container_name: bc-db
image: mysql:8.0
volumes:
- ./volumes/mysql:/var/lib/mysql
# - db-volume:/var/lib/mysql # Uncomment this line for Windows and comment out the line above
- ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "basercms"
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci --innodb-use-native-aio=0 --default_authentication_plugin=mysql_native_password
bc-php:
container_name: bc-php
image: baserproject/basercms:php8.1
volumes:
- ../:/var/www/html:delegated
environment:
PHP_IDE_CONFIG: "serverName=localhost"
XDEBUG_MODE: "debug"
XDEBUG_SESSION: "1"
COMPOSER_ALLOW_SUPERUSER: 1
ports:
- "80:80"
- "443:443"
depends_on:
- bc-db
command: bash -c "/var/www/html/docker/bin/init.sh && apache2-foreground"
bc-smtp:
container_name: bc-smtp
image: schickling/mailcatcher
ports:
- "1080:1080"
- "1025:1025"
bc-pma:
container_name: bc-pma
image: phpmyadmin
environment:
- PMA_ARBITRARY=1
- PMA_HOST=bc-db
- PMA_USER=root
- PMA_PASSWORD=root
links:
- bc-db
ports:
- 8080:80
volumes:
- ./phpmyadmin/sessions:/sessions
bc-pg:
image: postgres:15.2
container_name: bc-pg
ports:
- 5432:5432
volumes:
- ./volumes/postgres:/var/lib/postgres
- ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
user: root
bc-pga:
image: dpage/pgadmin4:7.8
container_name: bc-pga
ports:
- 8000:80
volumes:
- ./pgadmin:/var/lib/pgadmin/storage
environment:
PGADMIN_DEFAULT_EMAIL: foo@example.com
PGADMIN_DEFAULT_PASSWORD: root
depends_on:
- bc-pg
Overview of the entire file
This file is used to configure and manage multiple containers (virtual servers) together. Each container plays a specific role (database, web server, mail catcher, etc.).
version: '3'
This indicates the version of Docker Compose that this configuration file uses. Version 3 is the one widely used today.
services: 'services'
From here down, multiple services (containers) are defined. Each service has a name, such as bc-db
, bc-php
, bc-smtp
, etc., and its own configuration.
1. bc-db
(container for database)
container_name
: Create a container namedbc-db
.image
: Use an image of MySQL version 8.0 calledmysql:8.0
.volumes: (database container
for database)container_name
: bc-db./volumes/mysql:/var/lib/mysql
:on
the host (your PC)./volumes/mysql
directory on the host (your PC) to/var/lib/mysql
in the container. This will store the database data on the host.# - db-volume:/var/lib/mysql
: If you are using Windows, comment out the line above and uncomment this line..
/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
: directory to store scripts for database initialization.
ports
:3306:3306
to open MySQL’s standard port 3306 to the outside world.environment
: Environment variables to set the root password and database name.command
: command to configure MySQL.
2. bc-php
(container for web server using PHP and Apache)
container_name
: Create a container namedbc-php
.image
: Use the baserCMS imagenamed baserproject/basercms:php8.1
.volumes
:../:/var/www/html:delegated
: Mount one directory above the host to/var/www/html
in the container. This will store the web content on the host.
environment
: Configure PHP debugging settings and PHP package management tool called Composer.ports: The ports are used to
configure the80:80
: Open port 80 for HTTP.443:443
: Open port 443 for HTTPS.
depends_on
: Setbc-db
container to be started first.command
: Command to be executed at startup. Run/var/www/html/docker/bin/init.sh
before starting Apache (web server).
3. bc-smtp
(container for mail catcher)
- Create a container with the name
container_name
:bc-smtp
. image
: Use a mailcatcher image calledschickling/mailcatcher
. The mailcatcher is used to receive mail sent for testing purposes.ports
:1080:1080
: Ports to access the mailcatcher web interface.1025:1025
: Ports for the mail server.
4. bc-pma
(container for phpMyAdmin)
container_name
: Create a container namedbc-pma
.image
: Use an image fromphpmyadmin
, a database management tool.environment
: Configuration of phpMyAdmin. Specify database connection information.links
: Links to connect to thebc-db
container.ports
:8080:80
to expose port 8080 to access phpMyAdmin.volumes
:./phpmyadmin/sessions:/sessions
to store phpMyAdmin session data.
5. bc-pg
(container for PostgreSQL)
container_name
: Create a container namedbc-pg
.image
: Use the PostgreSQL database image namedpostgres:15.2
.ports
:5432:5432
to expose port 5432 to access PostgreSQL.volumes
:../volumes/postgres:/var/lib/postgres
: Store PostgreSQL data on the host../postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
: Store scripts for database initialization.
environment
: Initial PostgreSQL configuration.user
: Run the container asroot
.
6. bc-pga
(container for pgAdmin)
container_name
: Create a container namedbc-pga
.image
: Use the pgAdmin image nameddpage/pgadmin4:7.8
. pgAdmin is a tool to manage PostgreSQL.ports
:8000:80
to expose port 8000 to access pgAdmin.volumes
:./pgadmin:/var/lib/pgadmin/storage
to store pgAdmin configuration on the host.environment
: initialize pgAdmin configuration.depends_on
: Setbc-pg
container to be started first.
Steps to Set Up baserCMS with Docker
Launching a Test Container
First, launch the PHP container only. At this stage, the database is located on a separate machine, and phpMyAdmin is not used.
The command is as follows:
docker run --name test -d baserproject/basercms:php8.1
Specific Explanation Guidelines
1. Important Points When the Database is Located on a Separate Machine
This article assumes that the database is located on a separate machine or server. Therefore, the database-related settings in the docker-compose.yml.default
file (such as bc-db
and bc-pg
) are not necessary. If the database is external, you only need to start the PHP container and configure it to connect to the external database.
2. Steps to Set Up Only the PHP Container
First, launch a test PHP container and copy the configuration files from the container to the host. This step is necessary so that you can mount the copied files on the host and start the production container later.
docker run --name test -d baserproject/basercms:php8.1
To copy the configuration files from the container to the host, use the following commands:
docker exec -ti test bash
docker cp test:/usr/local/etc/php /root/bc-php/
docker cp test:/etc/apache2 /root/bc-apache2/
After stopping and deleting the test container, mount the files you copied to the host and start the production container.
docker run \
--name bc \
-p 8080:80 \
-v /root/bc-php:/usr/local/etc/php \
-v /root/bc-apache2:/etc/apache2 \
-v /root/basercms:/var/www/html \
-d baserproject/basercms:php8.1
3. Using the docker-compose.yml.default File
If you prefer to set up the database locally after understanding the above steps, you can use the docker-compose.yml.default
file to manage all services collectively. However, if the database is external, you do not need to use this file.
4. Suggested Instructions for Readers “When the Database is External”
If you already have a database on another server, do not use the docker-compose.yml.default
file. Instead, follow the above steps to launch only the PHP container. In this case, the database-related settings are not necessary.
Easy Setup Method
If you want to avoid complex procedures and set up easily, using the docker-compose.yml
file is convenient. This file contains the configuration for all the necessary containers (PHP, database, mail catcher, etc.).
Setup Procedure
Placing the File
Place the docker-compose.yml
file in the root directory of your project (the basercms
directory).
Running the Command
Simply run the following command to start all the services at once.
docker compose up -d
This command will start all the containers in the background based on the docker-compose.yml
file. The setup will be completed in a short time, and you will be able to verify the operation of baserCMS immediately.
Note for Windows Users
Volume Settings
If you are using Windows, you need to modify the comment lines in the docker-compose.yml
file. Specifically, uncomment the db-volume
line and comment out the line above it.
Host-side port permission settings
After setup, before accessing basercMS with a browser, it is necessary to allow traffic on the port to be used on the host side. In particular, if port 8080
is to be used, use the following command to allow it:
ufw allow 8080/tcp
Also, if you are using OracleCloud, remember to add an ingress rule in the security rules to allow access to port 8080
. If this setting is not sufficient, access from a browser may be blocked.
Confirming Access with a Browser
After all settings are complete, access the following URL with a browser to confirm that baserCMS is working properly.
http://IPアドレス:8080/
If an error occurs when accessing the site, please refer to the above troubleshooting each time you encounter the error.
Change the permissions of some directories in basercms since it is indicated that you do not have write permission.
Error on write permission
- If you get a “You do not have write permission” error message when accessing basercms, you will need to change the permissions on the following directories
cd basercms
chmod 777 composer vendor tmp logs config
- By executing this command, write permission will be granted to the necessary directories and the error will be resolved.
When I accessed the site again with a browser to check, the previous error seems to have been fixed, but a new error occurred.
Library installation failed.
Please try executing the command
cd /var/www/html/; export HOME=/var/www/html/composer/ ; yes | /usr/local/bin/php /var/www/html/composer/composer.phar update
Library installation fails
This procedure will create composer.phar
and install the required libraries.
If the library installation fails, try to install it manually by running the following commandcd /var/www/html/
export HOME=/var/www/html/composer/
yes | /usr/local/bin/php /var/www/html/composer/composer.phar update
Or enter the container and type the following command to solve the problem
docker exec -ti bc bash
cd composer
./composer.phar self-update
./composer.phar install
In addition, rename the configuration files in the config directory so that they can be used.
cp .env.example .env
Now that we can no longer proceed, we need to access it again.
http://IPアドレス:8080/
Again, I get a write permission error, but I will deal with it as before.
chmod 777 plugins webroot/files db
Problem of not being able to access the administration page
- If you cannot access the administration page of baserCMS, it may be because
localhost
has been entered in the URL address. In this case, edit the configuration file in theconfig
directory to set the URL address correctly.vi .env
- Enter the normal domain name for
SITE_URL
andSSL_URL
. If accessing via a reverse proxy,SITE_URL
must be set tohttp
andADMIN_SSL
must be set tofalse
.
If you don’t edit the environment configuration file in the config
directory of baserCMS, the URL address will default to localhost
, so you’ll need to edit the file.
vi .env
Enter the usual domain name for SITE_URL
and SSL_URL
. If you are accessing through a reverse proxy, set SITE_URL
to http
and ADMIN_SSL
to false
.
In my environment, communication within the LAN is done over http
, which is why ADMIN_SSL
needs to be set to false
to avoid errors.