From 4d511175c6138ffd063cbcaa189516ae66b32180 Mon Sep 17 00:00:00 2001 From: Marek Miklewicz <86836305+marsonpl@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:53:14 +0100 Subject: [PATCH] Create PHP configuration script for DirectAdmin This script generates PHP configuration files for different PHP versions found in the specified directories. It includes settings for opcache and other PHP directives, and rebuilds Apache/PHP configurations in DirectAdmin. --- php_settings.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 php_settings.sh diff --git a/php_settings.sh b/php_settings.sh new file mode 100644 index 0000000..81d245c --- /dev/null +++ b/php_settings.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +set -euo pipefail + +mapfile -t PHP_INI_DIRS < <(compgen -G "/usr/local/php*/lib/php.conf.d" || true) + +if [[ ${#PHP_INI_DIRS[@]} -eq 0 ]]; then + echo "Brak katalogów /usr/local/phpXX/lib/php.conf.d do przetworzenia." >&2 + exit 1 +fi + +for dir in "${PHP_INI_DIRS[@]}"; do + [[ -d "$dir" ]] || continue + + php_tag="$(basename "$(dirname "$(dirname "$dir")")")" + num="${php_tag#php}" + major="${num:0:1}" + + read -r -d '' OPCACHE_BLOCK <<'OPC_END' || true +[opcache] +opcache.enable=1 +opcache.enable_cli=0 +opcache.memory_consumption=256 +opcache.interned_strings_buffer=32 +opcache.max_accelerated_files=16229 +opcache.max_wasted_percentage=10 +opcache.revalidate_freq=10 +opcache.fast_shutdown=1 +opcache.enable_file_override=0 +opcache.max_file_size=0 +opcache.validate_timestamps=1 +opcache.revalidate_path=0 +OPC_END + + JIT_BLOCK="" + if [[ "$major" -ge 8 ]]; then + JIT_BLOCK=$'opcache.jit_buffer_size=256M\nopcache.jit=1255\n' + fi + + target="${dir}/20-hitme.ini" + echo "Tworzę ${target}" + + cat >"$target" </dev/null 2>&1; then + da build rewrite_confs +elif [[ -x /usr/local/directadmin/custombuild/build ]]; then + /usr/local/directadmin/custombuild/build rewrite_confs +else + echo "Nie znaleziono polecenia build rewrite_confs" >&2 + exit 2 +fi + +echo "Gotowe."