set -e
+echo "Installing PHP version '${1}'..."
+
SCRIPT_DIR="$(dirname -- "$(readlink -f "$0")")"
configure_php_ini() {
echo "always_populate_raw_post_data = -1" >> "${1}"
# we disable xdebug for speed for both cli and web mode
+ # @todo make this optional
if which phpdismod >/dev/null 2>/dev/null; then
phpdismod xdebug
elif [ -f /usr/local/php/$PHP_VERSION/etc/conf.d/20-xdebug.ini ]; then
DEBIAN_VERSION="$(lsb_release -s -c)"
if [ "${PHP_VERSION}" = default ]; then
+ echo "Using native PHP packages..."
+
if [ "${DEBIAN_VERSION}" = jessie -o "${DEBIAN_VERSION}" = precise -o "${DEBIAN_VERSION}" = trusty ]; then
PHPSUFFIX=5
else
done
if [ "${PHP_VERSION}" = 5.3 -o "${PHP_VERSION}" = 5.4 -o "${PHP_VERSION}" = 5.5 ]; then
- # @todo this set of packages has only been tested on Focal and Jammy so far
+ echo "Using PHP from shivammathur/php5-ubuntu..."
+
+ # @todo this set of packages has only been tested on Bionic, Focal and Jammy so far
if [ "${DEBIAN_VERSION}" = jammy ]; then
ENCHANTSUFFIX='-2'
fi
# we have to do this as the init script we get for starting/stopping php-fpm seems to be faulty...
pkill php-fpm
+ rm -rf "/usr/local/php/${PHP_VERSION}/var/run"
+ ln -s "/var/run/php" "/usr/local/php/${PHP_VERSION}/var/run"
+ # set up the minimal php-fpm config we need
echo 'listen = /run/php/php-fpm.sock' >> "/usr/local/php/${PHP_VERSION}/etc/php-fpm.conf"
# the user running apache will be different in GHA and local VMS. We just open fully perms on the fpm socket
echo 'listen.mode = 0666' >> "/usr/local/php/${PHP_VERSION}/etc/php-fpm.conf"
+ # as well as the conf to enable php-fpm in apache
cp "$SCRIPT_DIR/../config/apache_phpfpm_proxyfcgi" "/etc/apache2/conf-available/php${PHP_VERSION}-fpm.conf"
else
+ echo "Using PHP packages from ondrej/php..."
+
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
PHPVER=$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2>/dev/null)
+service "php${PHPVER}-fpm" stop || true
+
if [ -d /etc/php/${PHPVER}/fpm ]; then
configure_php_ini /etc/php/${PHPVER}/fpm/php.ini
elif [ -f /usr/local/php/${PHPVER}/etc/php.ini ]; then
# 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
if [ -f "/etc/init.d/php${PHPVER}-fpm" ]; then
ln -s "/etc/init.d/php${PHPVER}-fpm" /etc/init.d/php-fpm
fi
# reconfigure apache (if installed). Sadly, php will switch on mod-php and mpm_prefork at install time...
if [ -n "$(dpkg --list | grep apache)" ]; then
+ echo "Reconfiguring Apache..."
if [ -n "$(ls /etc/apache2/mods-enabled/php* 2>/dev/null)" ]; then
rm /etc/apache2/mods-enabled/php*
fi
a2enconf php${PHPVER}-fpm
service apache2 restart
fi
+
+echo "Done installing PHP"