Skip to content

Commit 8f645ea

Browse files
committed
New option: php version, fix #2
1 parent 78a6ec1 commit 8f645ea

6 files changed

Lines changed: 46 additions & 6 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; Configuration pour Xdebug 2 (PHP 5.x)
2+
zend_extension=xdebug.so
3+
4+
xdebug.remote_enable=1
5+
xdebug.remote_autostart=1
6+
xdebug.remote_connect_back=0
7+
; Remplacez par host.docker.internal sur Windows/Mac ou l'IP de votre hôte sur Linux
8+
xdebug.remote_host=host.docker.internal
9+
xdebug.remote_port=9003
10+
xdebug.remote_handler=dbgp
11+
xdebug.remote_mode=req
12+
13+
xdebug.idekey=docker
14+
xdebug.max_nesting_level=250

.docker/apachephp/98-xdebug.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; Configuration pour Xdebug 3 (PHP 7.0+)
12
xdebug.mode=debug,develop
23
xdebug.client_host=host.docker.internal
34
xdebug.client_port=9003

.docker/apachephp/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM php:8.4-apache
1+
ARG PHP_VERSION
2+
FROM php:${PHP_VERSION}-apache
3+
24
LABEL maintainer="J.GAUTHI <github.com/jgauthi>"
35

46
ENV \
@@ -11,8 +13,16 @@ ENV \
1113
USER_APACHE=www-data \
1214
WORKDIR=/var/www/project/demo
1315

16+
# Gestion des dépôts archives pour les vieilles versions (ex: PHP 5.6 sur Debian Jessie/Stretch)
17+
RUN if [ "$(echo $PHP_VERSION | cut -d. -f1)" = "5" ]; then \
18+
echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list && \
19+
echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list && \
20+
echo "Acquire::Check-Valid-Until false;" > /etc/apt/apt.conf.d/99no-check-valid-until && \
21+
echo "APT::Get::AllowUnauthenticated true;" > /etc/apt/apt.conf.d/99allow-unauthenticated; \
22+
fi
23+
1424
# Installation des outils, configuration du fuseau horaire ET des locales
15-
RUN apt-get update && apt-get install -y --no-install-recommends \
25+
RUN apt-get update && apt-get install -y --no-install-recommends --allow-unauthenticated \
1626
nano curl locales apt-utils supervisor tzdata \
1727
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && echo "${LANG} UTF-8" >> /etc/locale.gen && locale-gen \
1828
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \

.docker/apachephp/app.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
services:
22
app:
3-
build: .
3+
build:
4+
context: .
5+
args:
6+
- PHP_VERSION=${PHP_VERSION:-8.4}
47
ports:
58
- "8000:80"
69
volumes:
710
- ../../demo:/var/www/project/demo
811
# - ./97-memcached.ini:${PHP_INI_DIR}/97-memcached.ini
9-
- ./98-xdebug.ini:${PHP_INI_DIR}/98-xdebug.ini
12+
- ./${XDEBUG_CONFIG_FILE:-98-xdebug.ini}:${PHP_INI_DIR}/98-xdebug.ini
1013
- ./99-custom-php-conf.ini:${PHP_INI_DIR}/99-custom-php-conf.ini
1114
- ./apache_default.conf:${APACHE_CONF_DIR}/000-default.conf

.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ COMPOSE_PROJECT_NAME=poc_docker_apache_php
33
COMPOSE_PATH_SEPARATOR=,
44
COMPOSE_FILE=.docker/apachephp/app.yml
55
PHP_INI_DIR=/usr/local/etc/php/conf.d
6-
APACHE_CONF_DIR=/etc/apache2/sites-available
6+
APACHE_CONF_DIR=/etc/apache2/sites-available
7+
8+
# Optional environment variables
9+
# PHP_VERSION=5.6
10+
# XDEBUG_CONFIG_FILE=98-xdebug-php5.ini

readme.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Provide an dev environnement for Apache and php with a specific version.
66

77
* Docker v28+ & Docker compose v2.4+
88
* `Make` command. On linux, install with `sudo apt install build-essential`. On Windows, [see here](https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows/54086635).
9-
* These ports must be available for docker: `8000` _(you can change it on `.docker/apachephp/app.yml` or create a `docker-compose.override.yml` file after install)_.
9+
* These ports must be available for docker: `8000, 9003` _(you can change it on `.docker/apachephp/app.yml` or create a `docker-compose.override.yml` file after install)_.
1010

1111

1212
## Installation
@@ -15,6 +15,14 @@ Put your project files on **demo** folder _(you can rename if you edit docker/*/
1515
Exemple:
1616
```env
1717
COMPOSE_FILE=.docker/apachephp/app.yml,.docker/database/mysql.yml,.docker/database/phpmyadmin.yml
18+
19+
# [Optional] You can set php version, recommanded: 7.4, 8.4+
20+
PHP_VERSION=8.4
21+
22+
# [Optional] php5 support, recommanded: 5.6
23+
PHP_VERSION=5.6
24+
XDEBUG_CONFIG_FILE=98-xdebug-php5.ini
25+
1826
#...
1927
```
2028

0 commit comments

Comments
 (0)