From f8ee01ae606292e71248bd1e41805f99ae72defc Mon Sep 17 00:00:00 2001
From: Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
Date: Mon, 11 Jan 2021 13:39:54 +0100
Subject: [PATCH] =?UTF-8?q?R=C3=A9organisation=20des=20configs=20PHP=20par?=
 =?UTF-8?q?=20version=20car=20la=20config=20de=20xdebug=20v2=20(PHP=205.x)?=
 =?UTF-8?q?=20n'est=20pas=20pareille=20=C3=A0=20celle=20de=20la=20v3=20(PH?=
 =?UTF-8?q?P=207.x,=208.x).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGELOG.md                                     |  4 ++++
 Dockerfile-5.x                                   | 10 +++++++---
 Dockerfile-5.x.sh                                | 10 +++++++---
 Dockerfile-7.x                                   | 10 +++++++---
 Dockerfile-7.x.sh                                | 10 +++++++---
 Dockerfile-8.x                                   | 10 +++++++---
 Dockerfile-8.x.sh                                | 12 ++++++++----
 configs/{php-opcache.ini => php/5.x/opcache.ini} |  0
 configs/php/5.x/php.conf                         |  9 +++++++++
 configs/php/5.x/xdebug.conf                      | 11 +++++++++++
 configs/php/7.x/opcache.ini                      |  7 +++++++
 configs/php/7.x/php.conf                         |  9 +++++++++
 configs/{php.conf => php/7.x/xdebug.conf}        | 10 ----------
 configs/php/8.x/opcache.ini                      |  7 +++++++
 configs/php/8.x/php.conf                         |  9 +++++++++
 configs/php/8.x/xdebug.conf                      | 12 ++++++++++++
 16 files changed, 111 insertions(+), 29 deletions(-)
 rename configs/{php-opcache.ini => php/5.x/opcache.ini} (100%)
 create mode 100644 configs/php/5.x/php.conf
 create mode 100644 configs/php/5.x/xdebug.conf
 create mode 100644 configs/php/7.x/opcache.ini
 create mode 100644 configs/php/7.x/php.conf
 rename configs/{php.conf => php/7.x/xdebug.conf} (71%)
 create mode 100644 configs/php/8.x/opcache.ini
 create mode 100644 configs/php/8.x/php.conf
 create mode 100644 configs/php/8.x/xdebug.conf

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00d8189..72c7c0a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # CHANGELOG
 
+## 1.1.1
+
+- Réorganisation des configs PHP par version car la config de xdebug v2 (PHP 5.x) n'est pas pareille à celle de la v3 (PHP 7.x, 8.x).
+
 ## 1.1.0
 
 - Correction des Dockerfile pour forcer l'install de composer v1 (car la v2 génère des problèmes).
diff --git a/Dockerfile-5.x b/Dockerfile-5.x
index 6eec1e8..5561a22 100644
--- a/Dockerfile-5.x
+++ b/Dockerfile-5.x
@@ -16,6 +16,9 @@ ENV PHP_VERSION=${PHP_VERSION} \
     APACHE_CONF_DIR=/etc/apache2 \
     PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+ENV APACHE_CONF_LOCAL_DIR=configs/apache \
+    PHP_CONF_LOCAL_DIR=configs/php/5.x
+
 # Mise à niveau de la distrib
 RUN echo "Acquire::http::proxy \"${http_proxy}\";"  >> /etc/apt/apt.conf.d/proxy && \
     echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/proxy && \
@@ -93,8 +96,9 @@ RUN apt-get -qq update && \
 RUN update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP
-ADD configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-ADD configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+ADD ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 RUN pear config-set http_proxy "${http_proxy}"
@@ -115,7 +119,7 @@ RUN unzip -o /tmp/instantclient-basiclite-linux.x64-12.2.0.1.0.zip -d /usr/local
 # Apache
 RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
     a2dismod mpm_event && a2enmod mpm_worker
-ADD configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+ADD ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 RUN a2disconf security.conf && \
     a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/Dockerfile-5.x.sh b/Dockerfile-5.x.sh
index 0964047..2dd6d62 100755
--- a/Dockerfile-5.x.sh
+++ b/Dockerfile-5.x.sh
@@ -23,6 +23,9 @@ export OCI8_PACKAGE="oci8-2.0.12"
 export APACHE_CONF_DIR=/etc/apache2
 export PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+export APACHE_CONF_LOCAL_DIR=configs/apache
+export PHP_CONF_LOCAL_DIR=configs/php/5.x
+
 # Mise à niveau de la distrib
 echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/05proxy
 echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/05proxy
@@ -101,8 +104,9 @@ apt -qq update && \
 update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP.
-cp configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-cp configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+cp ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 cp resources/instantclient-basiclite-linux.x64-12.2.0.1.0.zip /tmp/
@@ -121,7 +125,7 @@ echo "/usr/local/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf &&
 
 a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
 a2dismod mpm_event mpm_prefork && a2enmod mpm_worker
-cp configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+cp ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 a2disconf security.conf && \
 a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/Dockerfile-7.x b/Dockerfile-7.x
index f01f8bc..f60987a 100644
--- a/Dockerfile-7.x
+++ b/Dockerfile-7.x
@@ -25,6 +25,9 @@ ENV PHP_VERSION=${PHP_VERSION} \
     APACHE_CONF_DIR=/etc/apache2 \
     PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+ENV APACHE_CONF_LOCAL_DIR=configs/apache \
+    PHP_CONF_LOCAL_DIR=configs/php/7.x
+
 # Mise à niveau de la distrib
 RUN echo "Acquire::http::proxy \"${http_proxy}\";"  >> /etc/apt/apt.conf.d/proxy && \
     echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/proxy && \
@@ -102,8 +105,9 @@ RUN apt-get -qq update && \
 RUN update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP
-ADD configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-ADD configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+ADD ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 RUN pear config-set http_proxy "${http_proxy}"
@@ -123,7 +127,7 @@ RUN unzip -o /tmp/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip -d /usr/l
 # Apache
 RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
     a2dismod mpm_event && a2enmod mpm_worker
-ADD configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+ADD ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 RUN a2disconf security.conf && \
     a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/Dockerfile-7.x.sh b/Dockerfile-7.x.sh
index fda98d2..8c4cb15 100755
--- a/Dockerfile-7.x.sh
+++ b/Dockerfile-7.x.sh
@@ -25,6 +25,9 @@ export OCI8_PACKAGE="oci8-2.2.0"
 export APACHE_CONF_DIR=/etc/apache2
 export PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+export APACHE_CONF_LOCAL_DIR=configs/apache
+export PHP_CONF_LOCAL_DIR=configs/php/7.x
+
 # Mise à niveau de la distrib
 echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/05proxy
 echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/05proxy
@@ -103,8 +106,9 @@ apt -qq update && \
 update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP.
-cp configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-cp configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+cp ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 cp resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/
@@ -122,7 +126,7 @@ echo "/usr/local/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf &&
 
 a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
 a2dismod mpm_event mpm_prefork && a2enmod mpm_worker
-cp configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+cp ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 a2disconf security.conf && \
 a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/Dockerfile-8.x b/Dockerfile-8.x
index 992f52a..1abbe10 100644
--- a/Dockerfile-8.x
+++ b/Dockerfile-8.x
@@ -25,6 +25,9 @@ ENV PHP_VERSION=${PHP_VERSION} \
     APACHE_CONF_DIR=/etc/apache2 \
     PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+ENV APACHE_CONF_LOCAL_DIR=configs/apache \
+    PHP_CONF_LOCAL_DIR=configs/php/8.x
+
 # Mise à niveau de la distrib
 RUN echo "Acquire::http::proxy \"${http_proxy}\";"  >> /etc/apt/apt.conf.d/proxy && \
     echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/proxy && \
@@ -102,8 +105,9 @@ RUN apt-get -qq update && \
 RUN update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP
-ADD configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-ADD configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+ADD ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+ADD ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 RUN pear config-set http_proxy "${http_proxy}"
@@ -123,7 +127,7 @@ RUN unzip -o /tmp/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip -d /usr/l
 # Apache
 RUN a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
     a2dismod mpm_event && a2enmod mpm_worker
-ADD configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+ADD ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 RUN a2disconf security.conf && \
     a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/Dockerfile-8.x.sh b/Dockerfile-8.x.sh
index 3c0577a..ee2f192 100755
--- a/Dockerfile-8.x.sh
+++ b/Dockerfile-8.x.sh
@@ -25,6 +25,9 @@ export OCI8_PACKAGE="oci8-3.0.0"
 export APACHE_CONF_DIR=/etc/apache2
 export PHP_CONF_DIR=/etc/php/${PHP_VERSION}
 
+export APACHE_CONF_LOCAL_DIR=configs/apache
+export PHP_CONF_LOCAL_DIR=configs/php/8.x
+
 # Mise à niveau de la distrib
 echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/05proxy
 echo "Acquire::https::proxy \"${http_proxy}\";" >> /etc/apt/apt.conf.d/05proxy
@@ -88,7 +91,7 @@ apt -qq update && \
         php${PHP_VERSION}-zip \
         php${PHP_VERSION}-cli \
         php${PHP_VERSION}-common \
-        php${PHP_VERSION}-json \
+        # php${PHP_VERSION}-json \ # inutile en PHP 8 car absorbé par php-fpm notamment
         php${PHP_VERSION}-opcache \
         php${PHP_VERSION}-readline \
         ssh \
@@ -103,8 +106,9 @@ apt -qq update && \
 update-alternatives --set php /usr/bin/php${PHP_VERSION}
 
 # Config PHP.
-cp configs/php.conf ${PHP_CONF_DIR}/fpm/conf.d/20-php-unicaen.ini
-cp configs/php-opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/20-opcache-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/opcache.ini ${PHP_CONF_DIR}/fpm/conf.d/90-opcache.ini
+cp ${PHP_CONF_LOCAL_DIR}/php.conf    ${PHP_CONF_DIR}/fpm/conf.d/91-unicaen.ini
+cp ${PHP_CONF_LOCAL_DIR}/xdebug.conf ${PHP_CONF_DIR}/fpm/conf.d/92-xdebug.ini
 
 # Package PHP Oracle OCI8
 cp resources/instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip /tmp/
@@ -122,7 +126,7 @@ echo "/usr/local/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf &&
 
 a2enmod actions alias rewrite ssl proxy proxy_fcgi setenvif headers && \
 a2dismod mpm_event mpm_prefork && a2enmod mpm_worker
-cp configs/apache/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
+cp ${APACHE_CONF_LOCAL_DIR}/security.conf ${APACHE_CONF_DIR}/conf-available/security-unicaen.conf
 a2disconf security.conf && \
 a2enconf security-unicaen.conf php${PHP_VERSION}-fpm
 
diff --git a/configs/php-opcache.ini b/configs/php/5.x/opcache.ini
similarity index 100%
rename from configs/php-opcache.ini
rename to configs/php/5.x/opcache.ini
diff --git a/configs/php/5.x/php.conf b/configs/php/5.x/php.conf
new file mode 100644
index 0000000..aca63b1
--- /dev/null
+++ b/configs/php/5.x/php.conf
@@ -0,0 +1,9 @@
+date.timezone = Europe/Paris
+
+log_errors = On
+display_startup_errors = On
+display_errors = On
+error_reporting = E_ALL
+
+upload_max_filesize = 51M
+post_max_size = 60M
diff --git a/configs/php/5.x/xdebug.conf b/configs/php/5.x/xdebug.conf
new file mode 100644
index 0000000..6065160
--- /dev/null
+++ b/configs/php/5.x/xdebug.conf
@@ -0,0 +1,11 @@
+# Xdebug v2
+xdebug.remote_enable = 0
+xdebug.remote_autostart = 1
+#xdebug.remote_host = 192.168.0.27
+xdebug.remote_port = 9000
+xdebug.idekey = PHPSTORM
+#xdebug.collect_params = 4
+xdebug.var_display_max_children = 1024
+xdebug.var_display_max_data = 1024
+xdebug.max_nesting_level = 256
+# Attention: trop diminuer 'max_nesting_level' peut causer une erreur 'Maximum function nesting level of x reached'
diff --git a/configs/php/7.x/opcache.ini b/configs/php/7.x/opcache.ini
new file mode 100644
index 0000000..592f72e
--- /dev/null
+++ b/configs/php/7.x/opcache.ini
@@ -0,0 +1,7 @@
+opcache.enable=0
+opcache.memory_consumption=128
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=4000
+opcache.revalidate_freq=60
+opcache.fast_shutdown=1
+opcache.enable_cli=1
diff --git a/configs/php/7.x/php.conf b/configs/php/7.x/php.conf
new file mode 100644
index 0000000..aca63b1
--- /dev/null
+++ b/configs/php/7.x/php.conf
@@ -0,0 +1,9 @@
+date.timezone = Europe/Paris
+
+log_errors = On
+display_startup_errors = On
+display_errors = On
+error_reporting = E_ALL
+
+upload_max_filesize = 51M
+post_max_size = 60M
diff --git a/configs/php.conf b/configs/php/7.x/xdebug.conf
similarity index 71%
rename from configs/php.conf
rename to configs/php/7.x/xdebug.conf
index cabad83..550ad14 100644
--- a/configs/php.conf
+++ b/configs/php/7.x/xdebug.conf
@@ -1,13 +1,3 @@
-date.timezone = Europe/Paris
-
-log_errors = On
-display_startup_errors = On
-display_errors = On
-error_reporting = E_ALL
-
-upload_max_filesize = 51M
-post_max_size = 60M
-
 # Xdebug v3
 xdebug.mode = develop,debug
 xdebug.client_host = localhost
diff --git a/configs/php/8.x/opcache.ini b/configs/php/8.x/opcache.ini
new file mode 100644
index 0000000..592f72e
--- /dev/null
+++ b/configs/php/8.x/opcache.ini
@@ -0,0 +1,7 @@
+opcache.enable=0
+opcache.memory_consumption=128
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=4000
+opcache.revalidate_freq=60
+opcache.fast_shutdown=1
+opcache.enable_cli=1
diff --git a/configs/php/8.x/php.conf b/configs/php/8.x/php.conf
new file mode 100644
index 0000000..aca63b1
--- /dev/null
+++ b/configs/php/8.x/php.conf
@@ -0,0 +1,9 @@
+date.timezone = Europe/Paris
+
+log_errors = On
+display_startup_errors = On
+display_errors = On
+error_reporting = E_ALL
+
+upload_max_filesize = 51M
+post_max_size = 60M
diff --git a/configs/php/8.x/xdebug.conf b/configs/php/8.x/xdebug.conf
new file mode 100644
index 0000000..550ad14
--- /dev/null
+++ b/configs/php/8.x/xdebug.conf
@@ -0,0 +1,12 @@
+# Xdebug v3
+xdebug.mode = develop,debug
+xdebug.client_host = localhost
+xdebug.client_port = 9003
+xdebug.start_with_request = yes
+xdebug.remote_handler = dbgp
+xdebug.discover_client_host = true
+xdebug.var_display_max_children = 1024
+xdebug.var_display_max_data = -1
+xdebug.max_nesting_level = 256
+# Attention: trop diminuer 'max_nesting_level' peut causer une erreur 'Maximum function nesting level of x reached'
+
-- 
GitLab