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

Сервис Apache HTTP server (PHP)

Веб-сервер Apache HTTP Server для отдачи PHP-приложений через связанный бэкенд PHP-FPM.

Вы добавляете этот сервис в стек и выбираете там его версию и ресурсы. Каждое окружение может их переопределить.

В StackMaster

Как Apache HTTP server (PHP) работает в StackMaster

What Wodby sets up for this web server. Apache here is configured by environment variables, by the config files the service declares and by the application's own .htaccess files.

How it is configured

On every start the container renders its configuration from templates and environment variables: conf/httpd.conf, conf/conf.d/vhost.conf (one virtual host) and conf/preset.conf under /usr/local/apache2. They are rewritten on each start; never edit them in a running container.

To change the configuration:

  • Set APACHE_* environment variables on the service.
  • Change the docroot setting.
  • Override the main configuration template or the virtual host template, both declared as config files of this service.
  • Add .htaccess files to the codebase: overrides are allowed in the document root (APACHE_ALLOW_OVERRIDE_ENABLED), and mod_rewrite, mod_headers, mod_expires and mod_deflate are loaded.

Preset

APACHE_VHOST_PRESET selects the rules included in the virtual host. This service uses the image default, html: files are served from the document root with index.html as the directory index (APACHE_DIRECTORY_INDEX). There is no fallback for paths that match no file; a single-page application needs its own rewrite rule in .htaccess. The image also ships a php preset, used by the PHP service built on this one.

Document root

The codebase is at /var/www/html. The docroot setting (variable DOCROOT_SUBDIR) names a subdirectory of the repository, and APACHE_DOCUMENT_ROOT is set to /var/www/html/ followed by it. Leave the setting empty to serve the repository root.

Always present

  • /.healthz returns 204 and is not logged. Use it for health checks.
  • Files and directories whose names start with a dot are denied, as are files ending in .sh, .sql, .mysql, .po, .tpl, .make or .test, wodby.yml and Makefile.
  • Directory listings are off unless APACHE_INDEXES_ENABLED is set.

Variables that matter most

VariableEffect
APACHE_DIRECTORY_INDEXdirectory index file
APACHE_ALLOW_OVERRIDE_ENABLEDwhat .htaccess files may override
APACHE_TIMEOUT, APACHE_REQUEST_READ_TIMEOUTrequest time limits
APACHE_LIMITED_ACCESSremoves the rule that grants access to everyone, so that access is defined elsewhere
APACHE_HTTP2accepts cleartext HTTP/2
APACHE_INCLUDE_CONFthe files included in place of the generated virtual host
APACHE_LOG_LEVELerror log level

Access and error logs go to the container's standard output and error.

Build and reaching the service

  • The image is built from the connected repository: the codebase is copied into the image at /var/www/html. Files are served from the built image, so a change needs a new build and deployment.
  • Other services reach it over HTTP on port 80 at the app service's name inside the environment.

Check the result

  • httpd -S prints the virtual host in effect; httpd -t checks the syntax.
  • curl -sI localhost/.healthz returns 204 from inside the container.

Apache for PHP on Wodby

What this service adds to the Apache service it is based on: it serves a PHP application's static files and passes PHP requests to the linked PHP service.

How requests are handled

The service sets APACHE_VHOST_PRESET to php:

  • The directory index is index.php (APACHE_DIRECTORY_INDEX).
  • A request for a .php file that exists under the document root is passed to the PHP service over FastCGI. A .php path with no file is not passed on.
  • Everything else is served by Apache as a file. The preset has no front controller rule: routing every path to index.php comes from the application's own .htaccess, which Apache reads.

Backend link

The link to a PHP-FPM service sets APACHE_BACKEND_HOST and APACHE_BACKEND_PORT, the FastCGI target. Apache passes the script as a path on its own disk, so the PHP service must have the code at the same path. Both images are built from the same source for that reason: this service has no repository of its own and is built from the source of the linked PHP service, copied to /var/www/html.

Document root

The docroot setting (variable DOCROOT_SUBDIR) has no default here: the repository root is served until it is set, for example to public or web. APACHE_DOCUMENT_ROOT is /var/www/html/ followed by it.

Variables that matter most

In addition to those of the Apache service: APACHE_FCGI_PROXY_TIMEOUT (how long Apache waits for PHP) and APACHE_FCGI_PROXY_CONN_TIMEOUT.

Static files

Static files are served from the built image: a changed asset needs a new build and deployment of this service.

Check the result

  • httpd -S prints the virtual host in effect.
  • curl -sI localhost/ from inside the container returns the application's response when the PHP service is reachable.

Обзор

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

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

Тип сервиса

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

Версии

2.4

Стеки

Стеки, в которые входит Apache HTTP server (PHP)

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

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

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

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

Технические домены

StackMaster выдаёт каждому публичному HTTP-порту технический домен с TLS-сертификатом и продлевает сертификат. Порт, который сервис помечает как частный, домен не получает. Можно добавить собственные домены.

Файлы конфигурации

2 файла конфигурации, которые стек или окружение могут переопределить.

Настройки

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

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

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