install.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. hestia_module_php_install() {
  3. source $HESTIA/bin/module/func.inc
  4. source $HESTIA/bin/module/php/func.inc
  5. if hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
  6. echo "PHP module is already installed. See 'hestia module info php'."
  7. return 0
  8. fi
  9. echo "Installing PHP module..."
  10. if [ "$OS_BASE" = 'debian' ]; then
  11. cat > /etc/apt/sources.list.d/php.list <<EOL
  12. # This file was added by Hestia Control Panel.
  13. deb https://packages.sury.org/php/ $OS_CODENAME main
  14. EOL
  15. apt-key adv --fetch-keys 'https://packages.sury.org/php/apt.gpg' > /dev/null 2>&1
  16. elif [ "$OS_BASE" = 'ubuntu' ]; then
  17. LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php > /dev/null 2>&1
  18. elif [ "$OS_BASE" = 'rhel' ]; then
  19. # Disable CentOS PHP, enable Remi PHP
  20. dnf -y module disable php
  21. dnf -y install http://rpms.remirepo.net/enterprise/remi-release-$OS_VERSION.rpm
  22. dnf config-manager --set-enabled remi remi-modular
  23. dnf -y module enable php:remi-$PHP_DEFAULT_VERSION
  24. fi
  25. # Install mod_php for system default PHP
  26. osal_package_preinstall
  27. osal_execute_with_spinner osal_package_install $PHP_PKG_MOD_PHP
  28. local pool_d=$(osal_php_fpm_pool_d $PHP_DEFAULT_VERSION)
  29. mkdir -p $pool_d
  30. mkdir -p $OSAL_PATH_RUN/php
  31. cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf $pool_d/www.conf
  32. osal_kv_write $HESTIA/conf/hestia.conf 'WEB_BACKEND' 'php-fpm'
  33. # Add default PHP version
  34. # Use --force, otherwise it will fail because technically PHP is still not installed
  35. echo "Adding default PHP version..."
  36. hestia module php add default --force
  37. return 0
  38. }