Тип сервиса
Сервис Apache HTTP server (PHP)
Веб-сервер Apache HTTP Server для отдачи PHP-приложений через связанный бэкенд PHP-FPM.
Вы добавляете этот сервис в стек и выбираете там его версию и ресурсы. Каждое окружение может их переопределить.
В StackMaster
Как Apache HTTP server (PHP) работает в StackMaster
.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
docrootsetting. - Override the main configuration template or the virtual host template, both declared as config files of this service.
- Add
.htaccessfiles to the codebase: overrides are allowed in the document root (APACHE_ALLOW_OVERRIDE_ENABLED), andmod_rewrite,mod_headers,mod_expiresandmod_deflateare 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
/.healthzreturns 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,.makeor.test,wodby.ymlandMakefile. - Directory listings are off unless
APACHE_INDEXES_ENABLEDis set.
Variables that matter most
| Variable | Effect |
|---|---|
APACHE_DIRECTORY_INDEX | directory index file |
APACHE_ALLOW_OVERRIDE_ENABLED | what .htaccess files may override |
APACHE_TIMEOUT, APACHE_REQUEST_READ_TIMEOUT | request time limits |
APACHE_LIMITED_ACCESS | removes the rule that grants access to everyone, so that access is defined elsewhere |
APACHE_HTTP2 | accepts cleartext HTTP/2 |
APACHE_INCLUDE_CONF | the files included in place of the generated virtual host |
APACHE_LOG_LEVEL | error 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 -Sprints the virtual host in effect;httpd -tchecks the syntax.curl -sI localhost/.healthzreturns 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
.phpfile that exists under the document root is passed to the PHP service over FastCGI. A.phppath 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.phpcomes 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 -Sprints 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)
Версии
Основан на
Репозиторий исходного кода
Публичный Helm-чарт
Стеки
Стеки, в которые входит Apache HTTP server (PHP)
Конфигурация
Конфигурация сервиса Apache HTTP server (PHP)
Технические домены
Файлы конфигурации
Настройки
Связи сервиса
Каждая связь — это подключение Apache HTTP server (PHP) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.
backend
Сервисы, которые подходят для этой связи