#!/bin/sh
+# Has to be run as admin
+
# To be kept in sync with setup_php_travis.sh
+# @todo make it optional to install xdebug. It is fe. missing in sury's ppa for Xenial
+# @todo make it optional to disable xdebug ?
+
set -e
configure_php_ini() {
+ # note: these settings are not required for cli config
echo "cgi.fix_pathinfo = 1" >> "${1}"
echo "always_populate_raw_post_data = -1" >> "${1}"
- # @todo this only disables xdebug for CLI. To do the same for the FPM config as well, should we use instead `phpdismod` ?
- XDEBUG_INI=$(php -i | grep xdebug.ini | grep -v '=>' | head -1)
- if [ "$XDEBUG_INI" != "" ]; then
- XDEBUG_INI="$(echo "$XDEBUG_INI" | tr -d ',')"
- mv "$XDEBUG_INI" "$XDEBUG_INI.bak";
- fi
+ # we disable xdebug for speed for both cli and web mode
+ phpdismod xdebug
}
# install php
php${PHPSUFFIX}-mbstring \
php${PHPSUFFIX}-xdebug
else
+ # on GHA runners ubuntu version, php 7.4 and 8.0 seem to be preinstalled. Remove them if found
+ for PHP_CURRENT in $(dpkg -l | grep -E 'php.+-common' | awk '{print $2}'); do
+ if [ "${PHP_CURRENT}" != "php${PHP_VERSION}-common" ]; then
+ apt-get purge -y "${PHP_CURRENT}"
+ fi
+ done
+
DEBIAN_FRONTEND=noninteractive apt-get install -y language-pack-en-base software-properties-common
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
apt-get update
configure_php_ini /etc/php/${PHPVER}/fpm/php.ini
-# use a nice name for the php-fpm service, so that it does not depend on php version running
+# use a nice name for the php-fpm service, so that it does not depend on php version running. Try to make that work
+# both for docker and VMs
service "php${PHPVER}-fpm" stop
-ln -s "/etc/init.d/php${PHPVER}-fpm" /etc/init.d/php-fpm
+if [ -f "/etc/init.d/php${PHPVER}-fpm" ]; then
+ ln -s "/etc/init.d/php${PHPVER}-fpm" /etc/init.d/php-fpm
+fi
+if [ -f "/lib/systemd/system/php${PHPVER}-fpm.service" ]; then
+ ln -s "/lib/systemd/system/php${PHPVER}-fpm.service" /lib/systemd/system/php-fpm.service
+ if [ ! -f /.dockerenv ]; then
+ systemctl daemon-reload
+ fi
+fi
# @todo shall we configure php-fpm?