Im want to create a docker container where I can serve my PHP project with Apache.
Right now I'm using php:8.3.16-cli-alpine3.20
as the base image. The project depends on numerous extensions which I add the following way:
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd redis intl protobuf mysqli
After that I install apache and copy it's configuration:
RUN apk add --no-cache apache2 php$phpverx-apache2
COPY ./default.conf /etc/apache2/httpd.conf
Here comes the problem. The php$phpverx-apache2
package overrides my PHP and because of this my project is not working. Is there any way I can tell apache to use my already installed PHP? I am thinking about adding LoadModule php_module path/to/my/php.so
, but I can't locate it on Alpine linux.
I would appreciate any help.
Use the fpm-alpine
base-image and do not install php$phpverx-apache2
inside. Instead bind your Apache2 HTTP application server to the PHP FPM version (via mod_proxy_fcgi, Examples (apache.org)).
RUN apk add --no-cache apache2 apache2-proxy
AFAIK the Docker PHP Alpine images do not ship with an Apache module.