Hello everyone, welcome to Webzone tech tips blog, I am Zidane. Today I will sharing my experience how to create Docker file and docker compose file for Apache, PHP 8.4 for running CakePHP 5
First I am access on the https://book.cakephp.org/ and check a requirement, i got below information
CakePHP has a few system requirements:
HTTP Server. For example: Apache. Having mod_rewrite is preferred, but by no means required. You can also use nginx, or Microsoft IIS if you prefer.
Minimum PHP 8.1 (8.4 supported).
mbstring PHP extension
intl PHP extension
SimpleXML PHP extension
PDO PHP extension
How to create Docker file and docker compose file for Apache, PHP 8.4 for running CakePHP 5 (Part 1)
π Tiktok
π Facebook:So I will create a Docker file with this one
We will setup some library curl, unzip, mbstring, intl simplexml, pdo for make sure can work on CakePHP 5 as requirement above
Docker file detail content
FROM php:8.4-apache
RUN apt-get update && apt-get install -y \
libonig-dev \
libicu-dev \
libxml2-dev \
libzip-dev \
curl \
unzip \
git \
&& docker-php-ext-install mbstring intl simplexml pdo pdo_mysql zip \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN a2enmod rewrite
WORKDIR /var/www/html
EXPOSE 80
Above command already integrated with compose, PHP 8.4 also.
After this one you can try to make a docker-compose.yml with below code
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8822:80"
volumes:
- ./src:/var/www/html
environment:
- APACHE_RUN_USER=www-data
- APACHE_RUN_GROUP=www-data
- APACHE_LOG_DIR=/var/log/apache2
- The volumes contain the source code will be ./src
- You can use command docker compose up -d for start this docker, compose
- After that you can use the compose, php on docker
by checking command docker exec -it <container_id> bash
Enjoy everyone!
Thanks for reading. Any feedback and questions. Leave your comment on below How to create Docker file and docker compose file for Apache, PHP 8.4 for running CakePHP 5 (Part 1), we can discuss about it.