How to Implement WordPress on Synology Using Docker Compose
Setting up WordPress on a Synology NAS with Docker Compose is a powerful way to manage your website efficiently. This guide will walk you through the steps to implement WordPress with the provided docker-compose.yml
file and ensure proper configuration of your Synology NAS, including the creation of necessary directories.
Prerequisites
- Synology NAS with Docker installed.
- SSH access to your Synology device (optional but recommended).
- Basic knowledge of Docker and Docker Compose.
- A text editor to modify configuration files.
Step 1: Prepare Your Synology NAS
Before deploying WordPress, create the necessary directories on your Synology NAS for storing persistent data.
- Log in to Synology DSM.
- Open File Station and navigate to a directory where you want to store your Docker data (e.g.,
/volume1/docker/
). - Create the following subdirectories:
/volume1/docker/wordpress/
/volume1/docker/wordpress/db
/volume1/docker/wordpress/redis
- Optionally, create an
upload.ini
file to customize PHP upload settings:
Open a text editor. Add the following content:
file_uploads = On
memory_limit = 512M
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 600
Save the file as upload.ini
in the /volume1/docker/wordpress/
directory.
Step 2: Install Docker Compose on Synology
- Open the Package Center on Synology DSM.
- Install the Docker package.
- SSH into your Synology NAS (optional) and ensure Docker Compose is installed. If not, you can manually install it by following Synology Docker documentation.
Step 3: Configure the docker-compose.yml
File
Use the provided docker-compose.yml
file to define your WordPress stack. Here’s the configuration:
services:
wordpress:
image: wordpress:php8.3
container_name: WordPress-Kexpiral
hostname: wordpress
ports:
- 8195:80
depends_on:
db:
condition: service_started
redis:
condition: service_healthy
phpmyadmin:
condition: service_healthy
volumes:
- /volume1/docker/wordpress/:/var/www/html:rw
- /volume1/docker/wordpress/upload.ini:/usr/local/etc/php/conf.d/uploads.ini:rw
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: $WORDPRESS_DB_USER
WORDPRESS_DB_PASSWORD: $WORDPRESS_DB_PASSWORD
WORDPRESS_DB_NAME: $WORDPRESS_DB_NAME
restart: on-failure:5
db:
image: mariadb:11.4-noble
container_name: WordPress-DB-Kexpiral
hostname: wordpress-db
environment:
MYSQL_DATABASE: $WORDPRESS_DB_NAME
MYSQL_USER: $WORDPRESS_DB_USER
MYSQL_PASSWORD: $WORDPRESS_DB_PASSWORD
MYSQL_ROOT_PASSWORD: $WORDPRESS_DB_PASSWORD
TZ: Europe/Madrid
volumes:
- /volume1/docker/wordpress/db:/var/lib/mysql:rw
restart: on-failure:5
redis:
image: redis
hostname: wordpress-redis-Kexpiral
container_name: WordPress-REDIS
healthcheck:
test: ["CMD-SHELL", "redis-cli ping || exit 1"]
volumes:
- /volume1/docker/wordpress/redis:/data:rw
environment:
TZ: Europe/Madrid
restart: on-failure:5
phpmyadmin:
image: phpmyadmin
hostname: wordpress-phpmyadmin-Kexpiral
container_name: WordPress-phpMyAdmin
ports:
- 2500:80
environment:
PMA_HOST: wordpress-db
PMA_PORT: 3306
restart: on-failure:5
Step 4: Deploy the Containers
- SSH into your Synology NAS or use the Synology Docker UI.
- Navigate to the directory where you saved the
docker-compose.yml
file. - Run the following command to start the containers:
docker-compose up -d
- Docker Compose will pull the necessary images, create the containers, and start the WordPress stack.
Step 5: Access WordPress
- Open a web browser and go to
http://<Synology-IP>:8195
. - Complete the WordPress installation by providing the following:
- Database Name:
kexpiral
(or the value set in$WORDPRESS_DB_NAME
). - Username: Your
$WORDPRESS_DB_USER
value. - Password: Your
$WORDPRESS_DB_PASSWORD
value. - Database Host:
db
.
Step 6: Access phpMyAdmin (Optional)
To manage the database, you can use phpMyAdmin:
- Open a web browser and go to
http://<Synology-IP>:2500
. - Log in with the database credentials you set in the
docker-compose.yml
file.
Conclusion
By following these steps, you’ve successfully set up WordPress on your Synology NAS using Docker Compose. This setup ensures data persistence and simplifies management, making it an excellent choice for both beginners and advanced users. Explore the potential of your Synology NAS and take full control of your WordPress environment!