Browse Source

PHP install fixes

Ernesto Nicolás Carrea 5 years ago
parent
commit
ea7d55e4bf

+ 17 - 4
bin/module/php-fpm/add.inc

@@ -36,12 +36,18 @@ hestia_module_php-fpm_add() {
         fi
     done
     if [ ! "$php_version" ]; then
-        echo "PHP version $param_ver is not supported."
+        echo "PHP (FPM( version $param_ver is not supported."
         return 1
     fi
 
     local php_withoutdot=${php_version//.}
-    local php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" && echo 1)
+    local php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" && echo 1)
+
+    if [ "$php_version_present" ] && [ ! "$param_force" ]; then
+        echo "PHP (FPM) version ${php_version} is already present. See 'hestia module php list'."
+        return 0
+    fi
+
 
     # Perform verification if read-only mode is enabled
     check_hestia_demo_mode
@@ -74,9 +80,16 @@ hestia_module_php-fpm_add() {
     cp -f $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl \
         $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
 
-    osal_kv_write $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_fpm" '1'
+    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" '1'
 
-    hestia module php-fpm integrate
+    if hestia_module_isinstalled 'php'; then
+        hestia module php add $php_version
+    fi
+
+    # Integrate everything
+    if [ ! "$param_without_no_integrate" ]; then
+        hestia module php-fpm integrate
+    fi
 
     log_history "installed php $php_version" '' 'admin'
 }

+ 4 - 4
bin/module/php-fpm/del.inc

@@ -38,9 +38,9 @@ hestia_module_php-fpm_del() {
 
     php_withoutdot=${php_version//.}
 
-    php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_fpm" && echo 1)
+    php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" && echo 1)
     if [ ! "$php_version_present" ] && [ ! "$param_force" ]; then
-        echo "PHP version ${php_version} is not present. See 'hestia module php list'."
+        echo "PHP (FPM) version ${php_version} is not present. See 'hestia module php list'."
         return 0
     fi
 
@@ -63,11 +63,11 @@ hestia_module_php-fpm_del() {
     # Cleanup files and folders
     [ -f $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl ] && hestia_safe_rm $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
 
-    osal_kv_write $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_fpm" '0'
+    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" '0'
 
     hestia module php-fpm integrate
 
-    log_history "removed php $phpversion" '' 'admin'
+    log_history "removed php-fpm $phpversion" '' 'admin'
 
     return 0
 }

+ 3 - 2
bin/module/php-fpm/install.inc

@@ -21,14 +21,15 @@ hestia_module_php-fpm_install() {
 
     cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf $pool_d/www.conf
 
+    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf 'installed' 1
     osal_kv_write $HESTIA/conf/hestia.conf 'WEB_BACKEND' 'php-fpm'
 
+    # Add FPM support for each CLI version installed
     for php_version in $PHP_SUPPORTED_VERSIONS; do
         php_withoutdot=${php_version//.}
         php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" 0)
         if [ "php_version_present" ]; then
-            # Use force, because FPM is technically still not installed
-            hestia module php-fpm add $php_version --force
+            hestia module php-fpm add $php_version
         fi
     done
 

+ 20 - 0
bin/module/php-fpm/list.inc

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+hestia_module_php-fpm_list() {
+    source $HESTIA/bin/module/func.inc
+    source $HESTIA/bin/module/php/func.inc
+
+    if ! hestia_module_isinstalled 'php-fpm' && [ ! "$param_force" ]; then
+        echo "PHP (FPM) module is not installed. See 'hestia module info php-fpm'."
+        return 1
+    fi
+
+    echo "Present PHP (FPM) versions"
+    for php_version in $PHP_SUPPORTED_VERSIONS; do
+        php_withoutdot=${php_version//.}
+        php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" 0)
+        echo "PHP ${php_version}: $(osal_bool_tostring $php_version_present 'present' 'not present')"
+    done
+
+    return 0
+}

+ 1 - 1
bin/module/php-fpm/remove.inc

@@ -11,7 +11,7 @@ hestia_module_php-fpm_remove() {
 
     for php_version in $PHP_SUPPORTED_VERSIONS; do
         php_withoutdot=${php_version//.}
-        php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_fpm" 0)
+        php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" 0)
         if [ "php_version_present" ]; then
             hestia module php-fpm del $php_version
         fi

+ 7 - 4
bin/module/php/add.inc

@@ -36,7 +36,7 @@ hestia_module_php_add() {
         fi
     done
     if [ ! "$php_version" ]; then
-        echo "PHP version $param_ver is not supported."
+        echo "PHP (CLI) version $param_ver is not supported."
         return 1
     fi
 
@@ -44,7 +44,7 @@ hestia_module_php_add() {
     local php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" && echo 1)
 
     if [ "$php_version_present" ] && [ ! "$param_force" ]; then
-        echo "PHP version ${php_version} is already present. See 'hestia module php list'."
+        echo "PHP (CLI) version ${php_version} is already present. See 'hestia module php list'."
         return 0
     fi
 
@@ -82,7 +82,10 @@ hestia_module_php_add() {
         hestia module php-fpm add $php_version
     fi
 
-    log_history "installed php $php_version" '' 'admin'
+    # Integrate everything
+    if [ ! "$param_without_no_integrate" ]; then
+        hestia module php integrate
+    fi
 
-    hestia module php integrate
+    log_history "installed php $php_version" '' 'admin'
 }

+ 1 - 1
bin/module/php/func.inc

@@ -1,4 +1,4 @@
 #!/bin/bash
 
-PHP_DEFAULT_VERSION=7.3
+PHP_DEFAULT_VERSION=7.4
 PHP_SUPPORTED_VERSIONS='5.6 7.0 7.1 7.2 7.3 7.4'

+ 7 - 12
bin/module/php/install.inc

@@ -21,29 +21,24 @@ EOL
         LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php > /dev/null 2>&1
     elif [ "$OS_BASE" = 'rhel' ]; then
         # Disable CentOS PHP, enable Remi PHP
-        dnf -y module disable php
-        dnf -y install http://rpms.remirepo.net/enterprise/remi-release-$OS_VERSION.rpm
+        dnf -yq module disable php
+        dnf -yq install http://rpms.remirepo.net/enterprise/remi-release-$OS_VERSION.rpm
         dnf config-manager --set-enabled remi remi-modular
-        dnf -y module enable php:remi-$PHP_DEFAULT_VERSION
+        dnf -yq module reset php
+        dnf -yq module enable php:remi-$PHP_DEFAULT_VERSION
     fi
 
     # Install mod_php for system default PHP
     osal_package_preinstall
     osal_execute_with_spinner osal_package_install $PHP_PKG_MOD_PHP
 
-    local pool_d=$(osal_php_fpm_pool_d $PHP_DEFAULT_VERSION)
-    mkdir -p $pool_d
-
     mkdir -p $OSAL_PATH_RUN/php
 
-    cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf $pool_d/www.conf
-
-    osal_kv_write $HESTIA/conf/hestia.conf 'WEB_BACKEND' 'php-fpm'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf 'installed' 1
     
     # Add default PHP version
-    # Use --force, otherwise it will fail because technically PHP is still not installed
-    echo "Adding default PHP version..."
-    hestia module php add default --force
+    echo "Adding default PHP (CLI) version..."
+    hestia module php add default
 
     return 0
 }

+ 2 - 2
bin/module/php/list.inc

@@ -5,11 +5,11 @@ hestia_module_php_list() {
     source $HESTIA/bin/module/php/func.inc
 
     if ! hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
-        echo "PHP module is not installed. See 'hestia module info php'."
+        echo "PHP (CLI) module is not installed. See 'hestia module info php'."
         return 1
     fi
 
-    echo "Present PHP versions"
+    echo "Present PHP (CLI) versions"
     for php_version in $PHP_SUPPORTED_VERSIONS; do
         php_withoutdot=${php_version//.}
         php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" 0)

+ 9 - 0
bin/module/php/show/default.inc

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+hestia_module_php_show_default() {
+    source $HESTIA/bin/module/func.inc
+    source $HESTIA/bin/module/php/func.inc
+
+    echo "Default PHP version: $PHP_DEFAULT_VERSION"
+    return 0
+}

+ 9 - 0
bin/module/php/show/supported.inc

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+hestia_module_php_show_default() {
+    source $HESTIA/bin/module/func.inc
+    source $HESTIA/bin/module/php/func.inc
+
+    echo "Supported PHP versions: $PHP_SUPPORTED_VERSIONS"
+    return 0
+}

+ 15 - 14
bin/package/web-server/integrate.inc

@@ -66,15 +66,26 @@ hestia_package_web-server_integrate() {
 
 
 
-    # *** PHP (FPM and CLI)
+    # *** PHP (CLI)
     if hestia_module_isinstalled 'php'; then
+        # Update default CLI version
+        if [ "$OS_BASE" = 'debian' ]; then    
+            update-alternatives --set php /usr/bin/php$PHP_DEFAULT_VERSION > /dev/null 2>&1
+        elif [ "$OS_BASE" == 'rhel' ]; then
+            local php_withoutdot=${PHP_DEFAULT_VERSION//.}
+            ln -sf /usr/bin/php$php_withoutdot /usr/bin/php
+        fi
+    fi
+
+    # *** PHP (FPM)
+    if hestia_module_isinstalled 'php-fpm'; then
         echo "Integrating PHP..."
         source $HESTIA/bin/module/php/func.inc
         for php_version in $PHP_SUPPORTED_VERSIONS; do
             local php_withoutdot=${php_version//.}
-            php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" 0)
+            php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" 0)
             if [ "$php_version_present" == "1" ]; then
-                echo " Enabling PHP $php_version"
+                echo " Enabling PHP (FPM) $php_version"
                 local php_prefix=$(osal_php_package_prefix $php_version)
                 osal_service_enable $php_prefix-fpm
                 osal_service_restart $php_prefix-fpm
@@ -89,18 +100,8 @@ hestia_package_web-server_integrate() {
             osal_apache_module_enable mpm_event > /dev/null 2>&1
             cp -f $HESTIA_INSTALL_DIR/$WEB_SYSTEM/hestia-event.conf $OSAL_PATH_APACHE_CONF_D/
         fi
-
-        # Update default CLI version
-        if [ "$OS_BASE" = 'debian' ]; then    
-            update-alternatives --set php /usr/bin/php$PHP_DEFAULT_VERSION > /dev/null 2>&1
-        elif [ "$OS_BASE" == 'rhel' ]; then
-            local php_withoutdot=${PHP_DEFAULT_VERSION//.}
-            ln -sf /usr/bin/php$php_withoutdot /usr/bin/php
-        fi
     fi
 
-
-
     # *** Rebuild IPs and domains
     if [ "$apache_installed" ] || [ "$nginx_installed" ] ; then
         # Install default success page
@@ -111,7 +112,7 @@ hestia_package_web-server_integrate() {
             cp -rf $HESTIA_INSTALL_DIR/templates/web/skel/document_errors/* /var/www/document_errors/
         fi
 
-        hestia package web-server setup-ips
+        hestia package web-server setup-ips  > /dev/null 2>&1
         
         # Rebuild domains
         echo "Rebuilding web domains..."