Mgrctl - ISPManager - включить cgi-fastcgi режим для user и сменить версию PHP для всех доменов - bash скрипт

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2026
Перейти к:навигация, поиск



Enable CGI and FastCGI (Apache) for the user + поставить всем доменам PHP 7.4.x

#!/bin/bash

MGRCTL="/usr/local/mgr5/sbin/mgrctl"

read -rp "Enter ISPmanager username: " USER

if [ -z "$USER" ]; then
    echo "Error: username is required"
    exit 1
fi

echo
echo "Enabling PHP modes for user: $USER"
echo

# Enable CGI and FastCGI (Apache) for the user
if "$MGRCTL" -m ispmgr user.edit \
    elid="$USER" \
    limit_php_mode_cgi=on \
    limit_php_mode_fcgi_apache=on \
    limit_php_cgi_version=isp-php74 \
    limit_php_mode=php_mode_fcgi_apache \
    sok=ok >/dev/null 2>&1
then
    echo "User PHP modes: OK"
else
    echo "ERROR: Failed to enable PHP modes for user '$USER'"
    exit 1
fi

echo
echo "Getting domains for user: $USER"
echo

DOMAINS=$(
    "$MGRCTL" -m ispmgr webdomain |
    awk -v user="$USER" '
        $0 ~ "owner=" user "($| )" {
            for (i=1; i<=NF; i++) {
                if ($i ~ /^name=/) {
                    sub(/^name=/, "", $i)
                    print $i
                    break
                }
            }
        }
    '
)

if [ -z "$DOMAINS" ]; then
    echo "No domains found for user: $USER"
    exit 1
fi

echo "Domains found:"
echo "$DOMAINS"
echo

while IFS= read -r DOMAIN; do

    [ -z "$DOMAIN" ] && continue

    echo -n "[$DOMAIN] "

    if "$MGRCTL" -m ispmgr webdomain.edit \
        elid="$DOMAIN" \
        php=on \
        php_mode=php_mode_fcgi_apache \
        php_cgi_version=isp-php74 \
        cgi=on \
        sok=ok >/dev/null 2>&1
    then
        echo "OK"
    else
        echo "FAILED"
    fi

done <<< "$DOMAINS"

echo
echo "========================================"
echo "Done"
echo "User: $USER"
echo "PHP: 7.4"
echo "CGI: enabled"
echo "FastCGI (Apache): enabled"
echo "========================================"
×
Реклама
ИКС