LCMP stack with Caddy as web server and PHP FPM, with MariaDB and phpMyAdmin.
Download the compose.yaml
file:
curl -O https://raw.githubusercontent.com/gremo/compose-selfhosted/main/src/lcmp/compose.yaml
Create an empty .env
file to hold environment variables:
touch .env
Create a test script in the public/
directory:
mkdir public && echo "<?php phpinfo();" > public/index.php
Tip
You can populate secrets in the .env
file randomly:
{
echo "DB_PASSWORD=$(head /dev/urandom | tr -dc 'A-Za-z0-9@$%&_+' | head -c10)"
echo
} >> .env
Important
Database root password is random, after starting the project run docker compose logs | grep -i "GENERATED ROOT PASSWORD"
and note it.
Supported variables:
Variable | Required | Default | Description |
---|---|---|---|
DOMAIN |
localhost | The domain name | |
DB_USER |
php | User for the DB_NAME database |
|
DB_PASSWORD |
Y | Password for the DB_NAME database |
|
DB_NAME |
app | Database name | |
PHP_EXTENSIONS |
@composer | PHP extensions to install |
docker compose up -d
Endpoint | Service |
---|---|
http://localhost | PHP-FPM |
http://localhost/phpmyadmin | phpMyAdmin |
A www redirection to non-www can be performed adding the following labels to the caddy
service:
labels:
caddy: www.${DOMAIN:-localhost}
caddy.redir: "http://${DOMAIN:-localhost}{uri}"