keshon/modx-docker-traefik
Docker environment setup for Nginx + PHP8
๐ MODx CMS with Docker & Traefik ๐
This repository sets up a MODx Content Management System environment using Docker, with Traefik as the reverse proxy for seamless HTTPS routing and management. This setup also includes PHPMyAdmin for database management.
๐ Project Structure
modx-docker-traefik/
โฃ db/ # Database data directory
โฃ db_backup/ # Database backups
โฃ nginx/
โ โ site.conf # NGINX server configuration
โฃ php/
โ โ dockerfile # PHP Dockerfile
โฃ www/ # Web root directory (place MODx files here)
โฃ .env # Environment variables
โฃ db_backup.sh # Backup script for database
โฃ db_dump.sh # Database dump script (being called from db_backup.sh)
โฃ docker-compose.yml # Docker Compose for build & deploy
โฃ fix_www_perm.sh # Script to set correct permissions for www directory
โ README.md # This readme file
โ๏ธ Prerequisites
Ensure you have the following installed on your machine:
- Docker (recent version can read docker-compose on its own) ๐ณ
- Traefik (installed separately for external
proxy network) ๐
๐ Getting Started
1. Clone the Repository
git clone https://github.com/keshon/modx-docker-traefik.git
cd modx-docker-traefik2. Configure Environment Variables
Set up the .env file for your MODx environment:
ALIAS=examplealias
HOST=example.com
PHPMYADMIN_DOMAIN=phpmyadmin.example.com
MYSQL_ROOT_PASSWORD=makeupyourrootpassword
DB_NAME=dbnameitself
DB_USER=dbusername
DB_PASSWORD=dbpassword3. Set Up docker-compose.yml
The docker-compose.yml file is configured for NGINX, PHP, MySQL, and PHPMyAdmin services:
- NGINX: Handles web requests and redirects with Traefik.
- PHP: The PHP environment for MODx.
- MySQL: Database service.
- PHPMyAdmin: Web-based MySQL admin tool.
4. Build and Launch the Stack
Run the following command to build and start the containers:
docker compose up -d๐ Note: Ensure Traefik is properly configured to use the
proxynetwork.
5. Access MODx and PHPMyAdmin
- MODx Site: http://yourdomain.com
- PHPMyAdmin: http://phpmyadmin.yourdomain.com
๐๏ธ Database Management
Backup the Database
Run the db_backup.sh script to back up the MySQL database.
./db_backup.shThe backup will be stored as an archive in the db_backup/ folder with a timestamp.
๐ ๏ธ Fix Permissions
Use fix_www_perm.sh to set proper permissions for the www/ directory:
./fix_www_perm.shThis ensures files are owned by www-data with proper read/write permissions.
โ๏ธ Configurations
NGINX Configuration
The NGINX configuration is in nginx/site.conf:
PHP Configuration
The PHP configuration (php/dockerfile) includes:
- Essential PHP extensions for MODx.
- Custom settings for file uploads, memory limits, and max execution time.
- By default php 8 is used but you can change it to 7 if needed.
๐ Additional Notes
- Traefik Configuration: Ensure your Traefik setup has a
proxynetwork accessible to this stack. - Volume Persistence: Data for MySQL is stored in
db/.
๐ License
This project is licensed under the MIT License. See the LICENSE file for details.