8.4 KiB
Installation
This guide covers a fresh manual deployment and the supplied local Docker development stack.
Requirements
- Use PHP 8.4, the runtime used by the supplied Docker image (
php:8.4-apache-bookworm). - Enable PHP's PDO MySQL driver (
pdo_mysql). - MySQL 8.0 or a compatible MySQL server.
- For Apache, enable
mod_rewriteandmod_dir, allow.htaccessoverrides for the project directory, and use the repository root as the document root. The included.htaccessusesFallbackResource /index.phpfor application routes. - The web-server user needs write access to the project
uploads/directory.
Configure the environment
From the project root, create the local environment and PHP configuration files required by the bootstrap:
cp .env.dist .env
cp config.dist.php config.php
The application loads .env from the project root, regardless of the web server's working directory. Keep both generated files local; .env and config.php are ignored by Git. Edit .env before serving the site:
| Variable | Purpose |
|---|---|
STAGE |
Use production for a deployed site. |
BASE_URL |
Public URL for the installation, for example https://example.com. For a subdirectory deployment, also configure the web server to route requests to this installation. |
DATABASE_DRIVER |
Use mysql. |
DATABASE_HOST |
Database server hostname; use mysql only when connecting to the Compose service. |
DATABASE_DATABASE |
Database name. |
DATABASE_USERNAME / DATABASE_PASSWORD |
Application database user credentials. |
DATABASE_CHARSET |
The DB connection charset; utf8mb4 is recommended. |
DATABASE_PREFIX |
Optional table prefix; leave empty unless required. |
MYSQL_ROOT_PASSWORD |
Compose-only MySQL root password; set it for local Docker development and do not use it as the app's database password. |
USERNAME |
Admin login name read directly by the existing Auth module. |
PASSWORD_HASH |
Recommended admin password value; generate it as shown below. |
PASSWORD |
Legacy plaintext fallback. Leave empty when using PASSWORD_HASH. |
MAIL_HOST, MAIL_PORT, MAIL_ENCRYPTION |
SMTP server settings. Encryption may be tls, ssl, or none. |
MAIL_USERNAME, MAIL_PASSWORD |
SMTP authentication credentials; leave empty when not required. |
MAIL_FROM_ADDRESS, MAIL_FROM_NAME |
Sender identity used by the mailer. |
MAIL_TIMEOUT |
SMTP connection timeout in seconds. |
Generate a password hash with PHP, then paste the output into PASSWORD_HASH:
php -r 'echo password_hash("choose-a-unique-password", PASSWORD_DEFAULT), PHP_EOL;'
PASSWORD_HASH takes precedence over PASSWORD. The plaintext option remains only for backward compatibility; do not use it for a production deployment. Keep .env private, restrict its filesystem permissions, and ensure the web server cannot serve dotfiles. Never commit it.
Manual deployment
-
Install PHP 8.4 with
pdo_mysql, MySQL 8, and Apache with the modules and.htaccesssettings listed above. -
Create an empty database and a dedicated application user. Grant that user the permissions needed to create and alter tables in this database; do not use the MySQL root account for the app.
For a local MySQL server, an administrator can use SQL similar to the following, replacing the sample password and adapting the user host for your deployment:
CREATE DATABASE plugi CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'plugi'@'localhost' IDENTIFIED BY 'replace-with-a-unique-password'; GRANT ALL PRIVILEGES ON plugi.* TO 'plugi'@'localhost'; -
Place the project in the web root, copy
.env.distto.envandconfig.dist.phptoconfig.php, and set the database name, user, password, host, publicBASE_URL, admin login, and any SMTP settings. For a non-Docker deployment,DATABASE_HOSTis usuallylocalhostor the database host provided by your hosting provider—notmysqlunless the host is actually namedmysql. -
Make
uploads/writable by the PHP/web-server user. Use the narrowest owner/group permissions appropriate to your server; avoid making the whole project world-writable. -
Open the configured
BASE_URL. Sign in with theUSERNAMEand password represented byPASSWORD_HASHat/admin/auth. -
On a fresh or outdated database, Plugi directs the administrator to the Website Manager database information/update flow. Use its database update action to create or update the schema, then reload the site.
The current schema definition is plugi-core/config/tables.php; the Website Manager update action applies the schema expected by the running application. Do not use plugi-core/config/create-tables.sql for a fresh setup: it is an old 2023 export and can be out of date. Back up any existing database before applying schema updates.
Local Docker development
The Compose stack is intended for local development only, not production. It uses PHP 8.4, MySQL 8.0, and the database hostname mysql; the web app and Adminer ports are bound to 127.0.0.1.
-
Copy
.env.distto.envandconfig.dist.phptoconfig.php. -
Set unique values for
DATABASE_PASSWORDandMYSQL_ROOT_PASSWORDin.env. The sameDATABASE_PASSWORD,DATABASE_DATABASE, andDATABASE_USERNAMEvalues are used to initialize MySQL and connect the app. These values are development examples only. -
Keep
DATABASE_HOST=mysqland setBASE_URL=http://localhost:63000for the supplied ports. Set the admin login and password hash as described above. -
Start the stack from the project root:
docker compose up --build -d -
Open
http://localhost:63000, sign in at/admin/auth, and use the Website Manager database update flow when prompted. Adminer is available athttp://localhost:63001; its database server name ismysql.
The MySQL data is stored in a named volume. docker compose down stops the stack without removing that volume; avoid docker compose down -v unless you intend to delete the database. Do not expose this development stack, its sample credentials, or Adminer as a production service.
Production and credential safety
- Use HTTPS, production-strength unique credentials, and least-privilege database access. Keep
.envout of version control and inaccessible over HTTP. - Configure the production web server to deny access to dotfiles and to the
.envfile explicitly; do not rely on a local Docker or Apache default for this protection. - The Compose stack and Adminer are development tools, not a production deployment recipe. Configure and harden production PHP, web server, database, backups, and monitoring separately.
- SMTP credentials were previously present in tracked configuration. Treat them as exposed and rotate them with the mail provider; removing them from the current files does not remove them from Git history.
Troubleshooting
- Missing
.env: Copy.env.distto.envin the project root. The loader requires this file at startup. - Missing
config.php: Copy the trackedconfig.dist.phptoconfig.phpin the project root; the bootstrap requires the local config file. - Database connection refused: Check that MySQL is running and
DATABASE_HOSTis correct. Usemysqlinside Compose and the actual host/localhostfor a manual deployment. - Access denied or unknown database: Check the exact
DATABASE_*names, database name, password, and grants. In Compose, the app and MySQL service must use the same database credentials. - Schema update repeats or fails: Confirm the database user can create/alter tables, back up existing data, and retry the Website Manager update flow. The application schema source is
plugi-core/config/tables.php. - Routes return 404 or the homepage is served incorrectly: Confirm the project root is the document root,
.htaccessoverrides are allowed, and Apache'smod_rewriteandmod_dirmodules are enabled. - A Docker port is already in use: Change the host-side port mapping in
docker-compose.yml(for example, map63002:80instead of63000:80) and updateBASE_URLin.envto the matching local URL. Do the same for Adminer if port63001is occupied. - Uploads fail: Confirm the web-server user can write to
uploads/and that the configured storage path points to the project directory. - Mail does not send: Check the
MAIL_*settings, sender address, SMTP port/encryption, and whether the provider requires authentication. The app will not have usable SMTP settings until configured.