I want to set up Cadddy, MariaDB and PHP 8.2 with FPM for hosting a Shopware 6 production installation on a virtual server running AlmaLinux 9.I 'm very new to this so any tips are highly appreciated!
I 've root access to the virtual server and set up the following directories
lcmp( for linux, caddy, mariadb, php)
in /lcmp I have the following directories and files
docker-compose.yaml /caddy_docker / www
Here is the docker - compose.yaml
#PHP Service php: build: './php_docker/'volumes: -. / www / :/var/www / html /
#Caddy Service caddy: build: './caddy_docker/'depends_on: -php ports: -"80:80" - "443:443"volumes: -. / www / :/var/www / html /
#MariaDB Service mariadb: image: mariadb: 10.11 environment: MYSQL_ROOT_PASSWORD: <root db pw volumes: -mysqldata: /var/lib / mysql
#phpMyAdmin Service phpmyadmin: image: phpmyadmin / phpmyadmin: latest ports: -8080 : 80 environment: PMA_HOST: mariadb depends_on: -mariadb
#Volumes volumes: mysqldata:
In / caddy_docker there is the Dockerfile
#Update package index and upgrade installed packages RUN apk update && apk upgrade
#Copy Caddyfile to configure Caddy server COPY Caddyfile / etc / caddy / Caddyfile```
and Caddyfile
```domain.tld: 80 {
reverse_proxy php: 9000 {
import php_common
}
}
(php_common) {
root * /var/www / html file_server php_fastcgi php: 9000 log {
output stdout
}
}```
In / php_docker I have(the extensions are required by Shopware 6) from
[https: //github.com/mlocati/docker-php-extension-installer][1]
```FROM php: 8.2 - fpm - alpine
#Downloading install - php - extensions script and making it executable ADD https: //github.com/mlocati/docker-php-extension-
installer / releases / latest / download / install - php - extensions / usr / local / bin / install - php - extensions RUN chmod + x / usr / local / bin / install - php - extensions
#Installing PHP extensions using install - php - extensions script RUN install - php - extensions\mysqli\pdo\pdo_mysql\gd\zip\intl\xml\curl\dom\fileinfo\iconv\json\libxml\mbstring\openssl\pcre\phar\simplexml\zlib
#Cleaning APK cache RUN rm - rf /
var / cache / apk
/*
In / www there is a simple index.php with
<?php phpinfo(); ?
I have a domain < domain.tld that when opened in the browser should show the index.php The domain is connected via DNS a records to the virtual server, there is no issues with that.
Docker was installed on this virtual server with the following steps
1. dnf upate
2. dnf install yum - utils
3. dnf config - manager--add - repo https: //download.docker.com/linux/centos/docker-ce.repo
4. sudo dnf install docker - ce docker - ce - cli containerd.io
then started and enabled with
systemctl start docker
systemctl enable docker
The docker service is up and running.Running docker compose up -d works here is the output
docker compose up -d
WARN[0000] Found orphan containers ([lcmp-apache-1]) for this project. If you removed
or renamed this service in your compose file, you can run this command
[+] Running 4/4
✔ Container lcmp-mariadb-1 Running
✔ Container lcmp-php-1 Running
✔ Container lcmp-phpmyadmin-1 Running
✔ Container lcmp-caddy-1 Started
Here is the output of
docker ps
CONTAINER ID IMAGE COMMAND
CREATED
STATUS PORTS NAMES
562fb44c3043 phpmyadmin/phpmyadmin:latest "/docker-entrypoint.…" 26 minutes ago
Up 26 minutes 0.0.0.0:8080-80/tcp, :::8080-80/tcp lcmp-phpmyadmin-1
8f778648eed9 mariadb:10.11 "docker-entrypoint.s…" 26 minutes ago
Up 26 minutes 3306/tcp lcmp-mariadb-1
59482a5db10a lcmp-php "docker-php-entrypoi…" 26 minutes ago
Up 26 minutes 9000/tcp lcmp-php-1
What I want:
- Open browser
- Enter domain.tld
- See output of index.php
What currently happens
Running curl localhost from the terminal returns
curl: (7) Failed to connect to localhost port 80: Connection refused
Entering domain.tld
domain.tld took too long to respond ERR_CONNECTION_TIMED_OUT*/
It works now, not sure about security but the content of whatever I put into the /www folder is displayed in the browser when entering the url specified in the Caddyfile now, sorry for the bad formatting in the original question, it was the only way I could post it. Anyways, here is my updated Caddyfile in /lcmp/caddy_docker
I've created two new directories in /lcmp/caddy_docker/
Here is the updated docker-compose.yaml in /lcmp