Просмотр исходного кода

Rename php-fpm to php, add CLI

Ernesto Nicolás Carrea 5 лет назад
Родитель
Сommit
4402c4a3dd

+ 0 - 9
bin/module/php-fpm/help.inc

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-hestia_module_php-fpm_help() {
-    echo "Usage:"
-    echo "  hestia module php-fpm list"
-    echo "  hestia module php-fpm add PHP_VERSION"
-    echo "  hestia module php-fpm del PHP_VERSION"
-    echo ""
-}

+ 0 - 15
bin/module/php-fpm/integrate.inc

@@ -1,15 +0,0 @@
-#!/bin/bash
-
-hestia_module_php-fpm_integrate() {
-    source $HESTIA/bin/module/php-fpm/func.inc
-    
-    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
-        echo ln -sf /usr/bin/php$php_withoutdot /usr/bin/php
-    fi
-
-    hestia package web-server integrate
-}

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

@@ -1,20 +0,0 @@
-#!/bin/bash
-
-hestia_module_php-fpm_list() {
-    source $HESTIA/bin/module/func.inc
-    source $HESTIA/bin/module/php-fpm/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 (FPM) ${php_version}: $(osal_bool_tostring $php_version_present 'present' 'not present')"
-    done
-
-    return 0
-}

+ 0 - 32
bin/module/php-fpm/remove.inc

@@ -1,32 +0,0 @@
-#!/bin/bash
-
-hestia_module_php-fpm_remove() {
-    source $HESTIA/bin/module/func.inc
-    source $HESTIA/bin/module/php-fpm/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 0
-    fi
-
-    echo "Removing PHP (FPM) module..."
-
-    # Remove all added versions
-    # FIXME: this will not remove unsupported but installed PHP versions
-    # (i.e. supported by an older version of Hestia)
-    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" '')
-        if [ "$php_version_present" ]; then
-            hestia module php-fpm del $php_version
-        fi
-    done
-
-    osal_kv_write $HESTIA/conf/hestia.conf 'WEB_BACKEND' 'no'
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf 'installed' '0'
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf 'description' ''
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf 'enabled' '0'
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf 'version' '0'
-
-    return 0
-}

+ 12 - 8
bin/module/php-fpm/add.inc → bin/module/php/add.inc

@@ -1,11 +1,11 @@
 #!/bin/bash
 
-hestia_module_php-fpm_add() {
+hestia_module_php_add() {
     source $HESTIA/bin/module/func.inc
-    source $HESTIA/bin/module/php-fpm/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'."
+    if ! hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
+        echo "PHP module is not installed. See 'hestia module info php'."
         return 1
     fi
 
@@ -17,6 +17,10 @@ hestia_module_php-fpm_add() {
         return 1
     fi
 
+    if [ "$param_ver" == "default" ]; then
+        param_ver="$PHP_DEFAULT_VERSION"
+    fi
+
     # Verify php version format
     if [[ ! "$param_ver" =~ ^[0-9]\.[0-9]+ ]]; then
         echo "The PHP version format is invalid, it should look like [0-9].[0-9]."
@@ -37,10 +41,10 @@ hestia_module_php-fpm_add() {
     fi
 
     local php_withoutdot=${php_version//.}
-    local php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" && echo 1)
+    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-fpm list'."
+        echo "PHP version ${php_version} is already present. See 'hestia module php list'."
         return 0
     fi
 
@@ -104,9 +108,9 @@ hestia_module_php-fpm_add() {
     #                       Hestia                             #
     #----------------------------------------------------------#
 
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" '1'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" '1'
 
     log_history "installed php $php_version" '' 'admin'
 
-    hestia module php-fpm integrate
+    hestia module php integrate
 }

+ 9 - 9
bin/module/php-fpm/del.inc → bin/module/php/del.inc

@@ -1,11 +1,11 @@
 #!/bin/bash
 
-hestia_module_php-fpm_del() {
+hestia_module_php_del() {
     source $HESTIA/bin/module/func.inc
-    source $HESTIA/bin/module/php-fpm/func.inc
+    source $HESTIA/bin/module/php/func.inc
 
-    if ! hestia_module_isinstalled 'php-fpm' && [ ! "$param_force" ]; then
-        echo "PHP module is not installed. See 'hestia module info php-fpm'."
+    if ! hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
+        echo "PHP module is not installed. See 'hestia module info php'."
         return 1
     fi
 
@@ -38,9 +38,9 @@ hestia_module_php-fpm_del() {
 
     php_withoutdot=${php_version//.}
 
-    php_version_present=$(osal_kv_read_bool $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" && echo 1)
+    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 (FPM) version ${php_version} is not present. See 'hestia module php-fpm list'."
+        echo "PHP (FPM) version ${php_version} is not present. See 'hestia module php list'."
         return 0
     fi
 
@@ -51,7 +51,7 @@ hestia_module_php-fpm_del() {
 
     php_etc_folder=$(osal_multiphp_etc_folder $php_version)
     hestia_config_backup 'php-del' $php_etc_folder \
-        $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
+        $HESTIA/data/templates/web/php/PHP-${php_version/\./_}.tpl
 
     php_prefix=$(osal_php_package_prefix $php_version)
 
@@ -80,9 +80,9 @@ hestia_module_php-fpm_del() {
     [ -f $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl ] && hestia_safe_rm $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
     [[ -d "$php_etc_folder" ]] && hestia_safe_rm "$php_etc_folder"
 
-    osal_kv_write $HESTIA_CONF_MODULES/php-fpm.conf "php${php_withoutdot}_present" '0'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" '0'
 
-    hestia module php-fpm integrate
+    hestia module php integrate
 
     log_history "removed php $phpversion" '' 'admin'
 

+ 0 - 0
bin/module/php-fpm/func.inc → bin/module/php/func.inc


+ 9 - 0
bin/module/php/help.inc

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+hestia_module_php_help() {
+    echo "Usage:"
+    echo "  hestia module php list"
+    echo "  hestia module php add PHP_VERSION"
+    echo "  hestia module php del PHP_VERSION"
+    echo ""
+}

+ 8 - 8
bin/module/php-fpm/install.inc → bin/module/php/install.inc

@@ -1,15 +1,15 @@
 #!/bin/bash
 
-hestia_module_php-fpm_install() {
+hestia_module_php_install() {
     source $HESTIA/bin/module/func.inc
-    source $HESTIA/bin/module/php-fpm/func.inc
+    source $HESTIA/bin/module/php/func.inc
 
-    if hestia_module_isinstalled 'php-fpm' && [ ! "$param_force" ]; then
-        echo "PHP (FPM) module is already installed. See 'hestia module info php-fpm'."
+    if hestia_module_isinstalled 'php' && [ ! "$param_force" ]; then
+        echo "PHP module is already installed. See 'hestia module info php'."
         return 0
     fi
 
-    echo "Installing PHP (FPM) module..."
+    echo "Installing PHP module..."
 
     if [ "$OS_BASE" = 'debian' ]; then
         cat > /etc/apt/sources.list.d/php.list <<EOL
@@ -33,12 +33,12 @@ EOL
 
     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/hestia.conf 'WEB_BACKEND' 'php'
     
     # Add default PHP version
-    # Use --force, otherwise it will fail because technically php-fpm is still not installed
+    # Use --force, otherwise it will fail because technically PHP is still not installed
     echo "Adding default PHP version ($PHP_DEFAULT_VERSION)..."
-    hestia module php-fpm add $PHP_DEFAULT_VERSION --force --default --no-integrate
+    hestia module php add $PHP_DEFAULT_VERSION --force --default
 
     return 0
 }

+ 1 - 13
bin/module/php/integrate.inc

@@ -1,17 +1,5 @@
 #!/bin/bash
 
 hestia_module_php_integrate() {
-    source $HESTIA/bin/module/func.inc
-    
-    if hestia_module_isinstalled 'apache'; then
-        local php_variant=$(hestia_module_variant_installed 'php')
-        if [ "$php_variant" = 'php-fpm' ]; then
-            # Enable mod_ruid/mpm_itk or mpm_event
-            # Disable prefork and php, enable event
-            osal_apache_module_disable php$fpm_v > /dev/null 2>&1
-            osal_apache_module_disable mpm_prefork > /dev/null 2>&1
-            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
-    fi
+    hestia package web-server integrate
 }

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

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+hestia_module_php_list() {
+    source $HESTIA/bin/module/func.inc
+    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'."
+        return 1
+    fi
+
+    echo "Present PHP 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)
+        echo "PHP ${php_version}: $(osal_bool_tostring $php_version_present 'present' 'not present')"
+    done
+
+    return 0
+}

+ 32 - 0
bin/module/php/remove.inc

@@ -0,0 +1,32 @@
+#!/bin/bash
+
+hestia_module_php_remove() {
+    source $HESTIA/bin/module/func.inc
+    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'."
+        return 0
+    fi
+
+    echo "Removing PHP module..."
+
+    # Remove all added versions
+    # FIXME: this will not remove unsupported but installed PHP versions
+    # (i.e. supported by an older version of Hestia)
+    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" '')
+        if [ "$php_version_present" ]; then
+            hestia module php del $php_version
+        fi
+    done
+
+    osal_kv_write $HESTIA/conf/hestia.conf 'WEB_BACKEND' 'no'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf 'installed' '0'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf 'description' ''
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf 'enabled' '0'
+    osal_kv_write $HESTIA_CONF_MODULES/php.conf 'version' '0'
+
+    return 0
+}

+ 1 - 1
bin/package/web-server/install.inc

@@ -21,7 +21,7 @@ hestia_package_web-server_install() {
 
     if [ $memory -ge 1572864 ] || [ "$param_withphp" ]; then
         if [ ! "$param_withoutphp" ]; then
-            hestia module install php-fpm --no-integrate
+            hestia module install php --no-integrate
         fi
     fi
 

+ 21 - 4
bin/package/web-server/integrate.inc

@@ -65,12 +65,12 @@ hestia_package_web-server_integrate() {
     osal_kv_write $HESTIA/conf/hestia.conf 'PROXY_SSL_PORT' $PROXY_SSL_PORT
 
     # *** PHP-FPM
-    if hestia_module_isinstalled 'php-fpm'; then
-        echo "Integrating PHP (FPM)..."
-        source $HESTIA/bin/module/php-fpm/func.inc
+    if hestia_module_isinstalled 'php'; 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-fpm.conf "php${php_withoutdot}_present" 0)
+            php_version_present=$(osal_kv_read $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" 0)
             if [ "$php_version_present" == "1" ]; then
                 echo " Enabling PHP $php_version"
                 local php_prefix=$(osal_php_package_prefix $php_version)
@@ -78,6 +78,23 @@ hestia_package_web-server_integrate() {
                 osal_service_restart $php_prefix-fpm
             fi
         done
+
+        if hestia_module_isinstalled 'apache'; then
+            # Enable mod_ruid/mpm_itk or mpm_event
+            # Disable prefork and php, enable event
+            osal_apache_module_disable php$fpm_v > /dev/null 2>&1
+            osal_apache_module_disable mpm_prefork > /dev/null 2>&1
+            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

+ 3 - 2
bin/package/web-server/remove.inc

@@ -3,10 +3,11 @@
 hestia_package_web-server_remove() {
     echo "Removing web server package..."
 
-    hestia module remove php-fpm --no-integrate
+    hestia module remove awstats --no-integrate
+    #TODO: remove non-default PHP versions, only leave default for CLI?
+    #hestia module remove php --no-integrate
     hestia module remove nginx --no-integrate
     hestia module remove apache --no-integrate
-    hestia module remove awstats --no-integrate
     
     # Integrate everything
     hestia package web-server integrate

+ 2 - 2
install/modules/php-fpm.hmd → install/modules/php.hmd

@@ -1,6 +1,6 @@
-name=php-fpm
+name=php
 provides=php
 requires=
 conflicts=
 preference=100
-description=PHP language FPM
+description=PHP language