Сервис приложения
Сервисы/PHP (WordPress)

Сервис PHP (WordPress)

Среда выполнения PHP для сайтов на WordPress со сборкой из исходного кода и связями с хранилищем контента и кешем.

Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.

В StackMaster

Как PHP (WordPress) работает в StackMaster

What Wodby sets up for an application that runs on this service. Check it before adding connection settings to the code.

Linked services

Links to other services reach the application as environment variables. Read them in code; do not hardcode hosts or credentials.

LinkVariables
Database (MariaDB, MySQL or PostgreSQL)DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION)
MailMSMTP_HOST, MSMTP_PORT
OpenTelemetry CollectorOTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL (http/protobuf), OTEL_EXPORTER_OTLP_HEADERS (the Collector's ingest token), OTEL_PHP_AUTOLOAD_ENABLED (true)

Mail needs no code: PHP's mail() is delivered through the linked mail service. An SMTP library or credentials in the codebase are not required.

A variable is present only while its link exists and the linked service is enabled.

The opentelemetry extension is enabled in the image. To send traces, add the OpenTelemetry PHP SDK, the OTLP exporter and an HTTP client with Composer (open-telemetry/sdk, open-telemetry/exporter-otlp and php-http/guzzle7-adapter), plus auto-instrumentation packages for the framework if wanted; with the link, the SDK configures itself from the variables above. Set OTEL_SERVICE_NAME to name the application in traces. Without the link the SDK stays off.

Generated configuration

On every start the container writes $CONF_DIR/wodby.settings.php (normally /var/www/conf/wodby.settings.php), a $wodby array with the environment's hosts, the files directory and the linked database's connection details. Framework services built on this one extend it and include it for the application. It is outside the codebase and rewritten on start: never edit it or copy its values into the repository. In a plain PHP application, read the variables above.

PHP settings

PHP and PHP-FPM are configured through environment variables on the service, such as PHP_MEMORY_LIMIT, PHP_MAX_EXECUTION_TIME or PHP_FPM_PM_MAX_CHILDREN, not through a php.ini in the repository. A change applies with the next deployment of the service.

Environment

  • WODBY_HOSTS is a JSON array of the environment's hosts; WODBY_PRIMARY_HOST and WODBY_PRIMARY_URL are the canonical ones for links generated outside a request.
  • WODBY_ENV_TYPE tells a development environment from a production-like one.

In a development workspace

  • The code is served from the checkout as it is on disk. PHP checks files for changes on every request, so an edit needs no restart.
  • PHP-FPM handles requests as wodby, the user that owns the checkout, so it reads what the developer can read and the files it writes stay editable over SSH.
  • Dependencies are installed by workspace setup with composer install; /vendor/ is kept out of Git status.
  • A change to variables or linked services still needs a deployment of the environment.

WordPress on Wodby

What Wodby sets up for a WordPress application on this service, in addition to the PHP service it is based on. Check it before adding database, URL, salt or Redis settings to wp-config.php.

What Wodby generates

On every start the container writes two files outside the codebase, from its environment variables:

  • $CONF_DIR/wodby.wp-config.php (normally /var/www/conf/wodby.wp-config.php): the Wodby configuration.
  • $CONF_DIR/wp-config.php: a complete wp-config.php that includes the file above and then wp-settings.php.

The generic wodby.settings.php of the PHP service is removed in this image; WordPress uses wodby.wp-config.php instead. Never edit the generated files or copy their values into the repository. They hold passwords: quote constant names, not values.

The web root is the repository root, or the subdirectory named by the docroot setting of this service (variable DOCROOT_SUBDIR, web by default). WordPress core is either in the web root, or in its wp subdirectory with wp-content next to it, as in the Wodby WordPress boilerplate. In the second layout Composer installs and updates core without touching the project's themes and plugins, the site answers at the web root and core, including wp-admin, at /wp. The WordPress root below is the directory that holds core: the web root, or <web root>/wp.

Init action

On container start the service runs its init action (WODBY2_SERVICE_INIT_ACTION, here init-wordpress) against the WordPress root:

  • With no wp-config.php there, it creates one that includes wodby.wp-config.php and then wp-settings.php.
  • With an existing wp-config.php that does not mention wodby.wp-config.php, it inserts the include, marked // Generated by Wodby, just before the line that loads wp-settings.php. Keep that include.
  • It makes wp-content and, when present, plugins, themes, upgrade, languages, cache, wp-rocket-config and wflogs under it writable by the web user.
  • It replaces wp-content/uploads with a link to the files volume. This fails when the directory in the codebase holds anything other than a .gitignore: keep uploads out of the repository.

What it configures

AreaConstantsFrom
Site URLWP_HOME, WP_SITEURL (<URL>/wp when core is in wp)WODBY_PRIMARY_URL
Content directoryWP_CONTENT_DIR, WP_CONTENT_URL, only when core is in wp: the web root's wp-contentWODBY_PRIMARY_URL, DOCROOT_SUBDIR
Changes from wp-adminDISALLOW_FILE_MODS, AUTOMATIC_UPDATER_DISABLED: no plugin, theme or core installs and updates, file editor or background updates, because the code is deployed as an imageWP_DISALLOW_FILE_MODS, WP_AUTOMATIC_UPDATER_DISABLED, set by this service
DatabaseDB_HOST (with the port when it is not 3306), DB_NAME, DB_USER, DB_PASSWORD, DB_CHARSET, DB_COLLATEDB_* of the linked database, DB_CHARSET, DB_COLLATION
Keys and saltsAUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY and the matching *_SALTWP_AUTH_KEY … WP_NONCE_SALT, generated by Wodby
Table prefix$table_prefixWP_TABLE_PREFIX
DebugWP_DEBUGWP_DEBUG
File systemFS_METHOD set to direct—
Redis or ValkeyWP_REDIS_HOST, WP_REDIS_PORT, WP_REDIS_PASSWORD, WP_REDIS_DATABASE, WP_REDIS_PREFIXREDIS_HOST, REDIS_PORT, REDIS_PASSWORD, REDIS_DATABASE, REDIS_PREFIX

Every constant is defined only when it is not defined yet, and $table_prefix only when it is not set. A value the project defines above the Wodby include therefore wins; do not define these constants there unless an override is intended.

The file also sets $_SERVER['HTTPS'] from the X-Forwarded-Proto header and $_SERVER['REMOTE_ADDR'] from X-Real-IP, so no proxy handling is needed in wp-config.php.

Redis or Valkey object cache

A linked Redis or Valkey service sets REDIS_HOST, REDIS_PORT and REDIS_PASSWORD on this service. The WP_REDIS_* constants are defined only while REDIS_HOST is not empty. Wodby defines the connection constants and nothing else: an object cache plugin that reads WP_REDIS_*, and enabling its object cache drop-in, are the project's part.

Files

  • The volume is mounted at $FILES_DIR (/mnt/files) and shared with the web server. wp-content/uploads points to $FILES_DIR/public.
  • Only uploads are on the volume. Add plugins and themes through the repository, with Composer or as committed code; the WordPress admin does not offer to install them.

Tools and scheduled work

  • WP-CLI is available as wp.
  • The service declares one cron job that runs wp cron event run --due-now against the WordPress root.

Changing configuration

Set environment variables on this service (WP_DEBUG, WP_TABLE_PREFIX, REDIS_DATABASE, REDIS_PREFIX, DB_CHARSET, DB_COLLATION, and the PHP_* variables of the PHP service), or change the docroot setting. The generated files pick the values up when the container starts after the next deployment.

This service has no development workspace.

Check the result

  • wp eval 'echo DB_HOST, PHP_EOL, WP_HOME, PHP_EOL;' --path=<WordPress root> shows values that came through the generated file.
  • wp eval 'var_dump(defined("WP_REDIS_HOST"));' --path=<WordPress root> tells whether the Redis constants are defined.
  • wp db check --path=<WordPress root> confirms the database connection.

Обзор

Технический профиль PHP (WordPress)

Здесь перечислены версии, которые можно выбрать для PHP (WordPress) в стеке или окружении. Сам сервис публикуется ревизиями, и стек ссылается на конкретную ревизию.

Тип сервиса

Сервис приложения

Версии

8.5, 8.4, 8.3, 8.2

Основан на

Постоянные тома

WP content

Стеки

Стеки, в которые входит PHP (WordPress)

PHP (WordPress) входит в этот публичный стек. Можно создать приложение из публичного стека как есть или добавить сервис в собственный стек.

CI/CD

Сборка PHP (WordPress) из Git-репозитория

Начните с публичного шаблона проекта или подключите собственный репозиторий. В StackMaster CI push в ветку, за которой следит окружение, запускает сборку PHP (WordPress), а пайплайн её развёртывает.

Vanilla WordPress

Используйте его как есть или клонируйте в свой Git-аккаунт.

wodby/wordpress-vanilla

Git-провайдеры

Репозиторий подключается через интеграцию с его Git-провайдером.

CI-провайдеры

StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.

Реестры контейнеров

Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.

Переменные окружения из интеграций

Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к PHP (WordPress), и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.

Конфигурация

Конфигурация сервиса PHP (WordPress)

Сервис PHP (WordPress) объявляет следующее. Если значение можно изменить, его задаёт стек, а каждое окружение может его переопределить.

Тома

WP content

Настройки

1 настройка, которую стек или окружение могут изменить.

Расписания cron

1 задача по расписанию. Каждый запуск создаёт задачу с логами.

Связи сервиса

Каждая связь — это подключение PHP (WordPress) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.

redis

Сервисы, которые подходят для этой связи

sendmail

Сервисы, которые подходят для этой связи