Help Center

PHP + Laravel + MariaDB

Laravel is the most used PHP framework for custom applications: the Eloquent ORM, migrations, a queue system, authentication and its own templating engine, all with a very well-crafted syntax.

This Stack combines it with MariaDB.

Included services

In addition to your application, the Stack starts MariaDB, an nginx that receives traffic on port 80, an automatic backups service and the web file manager.

Project structure

text
.
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ app
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ bootstrap
β”‚   β”‚   β”œβ”€β”€ app.php
β”‚   β”‚   └── providers.php
β”‚   β”œβ”€β”€ config
β”‚   β”‚   β”œβ”€β”€ app.php
β”‚   β”‚   └── database.php
β”‚   β”œβ”€β”€ public
β”‚   β”‚   └── index.php
β”‚   β”œβ”€β”€ routes
β”‚   β”‚   β”œβ”€β”€ console.php
β”‚   β”‚   └── web.php
β”‚   β”œβ”€β”€ artisan
β”‚   └── composer.json
β”œβ”€β”€ backup
β”‚   └── backup-runner.sh
β”œβ”€β”€ nginx
β”‚   └── default.conf
β”œβ”€β”€ .env.example
β”œβ”€β”€ app.Dockerfile
└── compose.yaml

Getting started

Install the Stack and start it:

bash
docker-deploy-stack --stack php/laravel-mariadb
cd /root/stack/php/laravel-mariadb
docker compose up -d

Then replace the example application with yours, from Git, via SFTP or using the web file manager, following how-do-i-deploy-an-application-on-a-stack.md. Your code goes in the app/ folder.

Each time you update the code, apply the changes:

bash
docker compose up -d --build

Configuration

Editable values are in the Stack’s .env file:

Variable Default Purpose
APP_PORT 80 Public port of the Stack.
APP_ENV development Application environment.
DB_NAME laravel Database name.
DB_USER laravel Database user.
BACKUP_ENABLED 1 Automatic backups: 1 enabled, 0 disabled.
BACKUP_INTERVAL_SECONDS 86400 How many seconds between backups.
BACKUP_RETENTION_DAYS 7 How many days backups are retained.
MARIADB_VERSION 11.4 Version of the corresponding image.

After changing it, apply the changes with docker compose up -d.

Useful commands

bash
docker compose ps          # see the containers that are running
docker compose logs -f     # view live logs
docker compose restart     # restart the services
docker compose down        # stop and remove the containers
Guide g.0309 Β· Source version 1 Β· en