English | 简体中文
Make sure Git is installed on your server. If not, you need to install the git
software first:
git clone https://github.com/seatonjiang/monolith.git
Navigate to the project folder:
cd monolith/
Rename the environment config file (if you don't execute this command, Docker Compose will throw an error due to missing environment variables):
cp env.example .env
vi .env
Check the environment config:
# PHP pre-installed extensions
PHP_EXTENSIONS=redis,memcached,opcache,pdo_mysql,mysqli,zip,gd,imagick,bz2,exif,bcmath,intl,mcrypt,ioncube_loader
# PHP environment
PHP_ENVIRONMENT=production
# MariaDB database name
DB_MARIADB_DATABASE_NAME=monolith
# phpMyAdmin WEB Port
PHPMYADMIN_WEB_PORT=28080
Modify the files in the secrets
directory. The mariadb-root-pwd
file contains the MariaDB root password, the mariadb-user-name
file contains the MariaDB user name, and the mariadb-user-pwd
file contains the MariaDB user password.
Build and run all containers in the background:
sudo docker compose up -d
For local development environment, access the website using localhost
. For production environment, use the server IP to access the website.
For example, the default page is http://localhost
, and the phpMyAdmin page is http://localhost:28080
.
The folder structure of the entire project, with the files in the folder omitted from the display:
monolith
├── data
│ ├── composer Composer data directory
│ ├── mariadb MariaDB data directory
│ └── redis Redis data directory
├── logs
│ ├── openresty OpenResty log directory
│ └── php PHP log directory
├── secrets
│ ├── mariadb-root-pwd MariaDB administrator password
│ ├── mariadb-user-name MariaDB username
│ └── mariadb-user-pwd MariaDB user password
├── services
│ ├── mariadb MariaDB config directory
│ ├── openresty OpenResty config directory
│ ├── php PHP config directory
│ └── redis Redis config directory
├── wwwroot Web service root directory
├── compose.yaml Docker Compose config file
└── env.smaple Example environment config file
# Build and run all containers in the background
sudo docker compose up -d
# Build and run specified containers in the background
sudo docker compose up -d openresty php mariadb
# Stop all containers and remove the network
sudo docker compose down
# Manage a specific service (using PHP as an example here)
sudo docker compose start php # Start the service
sudo docker compose stop php # Stop the service
sudo docker compose restart php # Restart the service
sudo docker compose build php # Rebuild the service
During the maintenance process, it is often necessary to enter containers using docker exec -it
. Here are some commonly used commands:
# Execute a command in a running PHP container
sudo docker exec -it php /bin/sh
# Execute a command in a running Nginx container
sudo docker exec -it openresty /bin/sh
# Execute a command in a running Redis container
sudo docker exec -it redis /bin/sh
# Execute a command in a running Memcached container
sudo docker exec -it memcached /bin/sh
# Execute a command in a running phpMyAdmin container
sudo docker exec -it phpmyadmin /bin/bash
# Execute a command in a running Mariadb container
sudo docker exec -it mariadb /bin/bash
After change the Nginx config file, you need to execute this command to make it take effect:
sudo docker exec -it openresty nginx -s reload
Installing PHP extensions using install-php-extensions
requires modifying the PHP_EXTENSIONS
variable in the .env
config file and then rebuilding the PHP container.
sudo docker compose build php
Supported PHP Extensions:https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions
Before executing the command for the first time, it is recommended to change the mirrors:
sudo docker exec -it php /bin/sh
composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
Modify the services/php/www.conf
file with two lines and remove the comments (recommended to be turned off for production environments):
slowlog = /var/log/php/slowlog.log
request_slowlog_timeout = 3
Modify the services/mariadb/mariadb.cnf
file by changing two lines to 1 (0 is required for production environments):
slow_query_log = 1
log_queries_not_using_indexes = 1
Modify the services/redis/redis.conf
file to find the requirepass
parameter and change the password:
requirepass foobared
We welcome all contributions. You can submit any ideas as Pull requests or as Issues, have a good time!
The project is released under the MIT License, see the LICENCE file for details.