Skip to content

Commit 4a42c06

Browse files
authored
Update v-import-cpanel Fix 500 Error from php version (hestiacp#4144)
* Update v-import-cpanel Fix 500 Error from php version Some users reported 500 Error after migration so I edited the script to check the installed versions on hestia and set the php version based on the backup file if it available * Update v-import-cpanel Change bin path to $BIN
1 parent 699b4e3 commit 4a42c06

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

bin/v-import-cpanel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,27 @@ rsync -av --exclude-from='exclude_path' homedir/public_html/ /home/$new_user/web
251251
chown $new_user:$new_user -R /home/$new_user/web/$main_domain1/public_html
252252
chmod 751 /home/$new_user/web/$main_domain1/public_html
253253

254+
####### Set Domain PHP version
255+
PHP_VERSION_LINE=$(grep -r "phpversion:" userdata/$main_domain1)
256+
CPANEL_PHP_VERSION=${PHP_VERSION_LINE#*: }
257+
CPANEL_PHP_VERSION=$(echo $CPANEL_PHP_VERSION | grep -oP '(?<=php)\d+')
258+
HESTIA_PHP_VERSION="PHP-${CPANEL_PHP_VERSION:0:1}_${CPANEL_PHP_VERSION:1}"
259+
260+
if $BIN/v-list-web-templates-backend | grep -qw "$HESTIA_PHP_VERSION"; then
261+
echo "Setting PHP version to $HESTIA_PHP_VERSION for $main_domain1 under user $new_user"
262+
$BIN/v-change-web-domain-backend-tpl $new_user $main_domain1 $HESTIA_PHP_VERSION
263+
if [ $? -ne 0 ]; then
264+
echo "Failed to set PHP version for $main_domain1"
265+
exit 1
266+
else
267+
echo "PHP version for $main_domain1 set to $HESTIA_PHP_VERSION"
268+
fi
269+
else
270+
echo "PHP version $HESTIA_PHP_VERSION is not installed on HestiaCP."
271+
echo "Please install it before trying to set it for a domain."
272+
exit 1
273+
fi
274+
254275
##################
255276
# mail
256277
tput setaf 2

0 commit comments

Comments
 (0)