V-import-cpanel PHP Issue, PHP version not being detected correctly

Hi There,

I’m trying to import and move my cpanel website and emails to hestia, but it fails with an PHP error. The version installed on my cpanel is v8.2 and it is defiantly installed on hestia. It looks like the import script could be detecting it as PHP-_

PHP version PHP-_ is not installed on HestiaCP.
Please install it before trying to set it for a domain.

The script I am using is the v-import-cpanel /backup/backup.tar.gz yes
The backup file size is around 5GB

Thanks!

Hi @mrea ,

Can you create a new user with website and PHP by the web version?

Hi @Aartsie do you mean new user on cpanel or new user in hestia and import under that user? The website is a wordpress website, I could take a backup of the site and try load it? Would I still be able to do a cpanel import to get all my other settings and emails?

No you can’t import from a cpanel backup when the user already exists if i’m correctly.

But i was wondering is it possible to create a new user in HestiaCP and setup a clean wordpess website whitout errors. Maybe there is a problem with you PHP version on the server. This is just as test case.

The part of code that check php version is this:

####### Set Domain PHP version
PHP_VERSION_LINE=$(grep -r "phpversion:" userdata/$main_domain1)
CPANEL_PHP_VERSION=${PHP_VERSION_LINE#*: }
CPANEL_PHP_VERSION=$(echo $CPANEL_PHP_VERSION | grep -oP '(?<=php)\d+')
HESTIA_PHP_VERSION="PHP-${CPANEL_PHP_VERSION:0:1}_${CPANEL_PHP_VERSION:1}"

if $BIN/v-list-web-templates-backend | grep -qw "$HESTIA_PHP_VERSION"; then
    echo "Setting PHP version to $HESTIA_PHP_VERSION for $main_domain1 under user $new_user"
    $BIN/v-change-web-domain-backend-tpl $new_user $main_domain1 $HESTIA_PHP_VERSION
    if [ $? -ne 0 ]; then
        echo "Failed to set PHP version for $main_domain1"
        exit 1
    else
        echo "PHP version for $main_domain1 set to $HESTIA_PHP_VERSION"
    fi
else
    echo "PHP version $HESTIA_PHP_VERSION is not installed on HestiaCP."
    echo "Please install it before trying to set it for a domain."
    exit 1
fi

##################

Seems it is not getting the right php version from your backup:

PHP_VERSION_LINE=$(grep -r "phpversion:" userdata/$main_domain1)

I don’t use or have access to CPanel so I can’t debug it to know what is the root cause for the error but you could decompress your backup and this execute command (replacing $main_domain1 by your actual main domain) to know what is getting:

grep -r "phpversion:" userdata/$main_domain1
1 Like

Hi @sahsanu I have just tried that, the command goes through but does not return anything? Should it be getting displayed or is it being stored elsewhere?

It should return something.

Because you unpacked /backup/backup.tar.gz and the userdata directory and file for main domain exists, right?

As you were using php 8.2 in CPanel and you will also use 8.2 in Hestia (it’s the default), you could edit the script and comment out the code that checks the php version.

1.- Backup script /usr/local/hestia/bin/v-import-cpanel

cp /usr/local/hestia/bin/v-import-cpanel /usr/local/hestia/bin/v-import-cpanel.backup

2.- Edit script /usr/local/hestia/bin/v-import-cpanel and comment out this code:

####### Set Domain PHP version
#PHP_VERSION_LINE=$(grep -r "phpversion:" userdata/$main_domain1)
#CPANEL_PHP_VERSION=${PHP_VERSION_LINE#*: }
#CPANEL_PHP_VERSION=$(echo $CPANEL_PHP_VERSION | grep -oP '(?<=php)\d+')
#HESTIA_PHP_VERSION="PHP-${CPANEL_PHP_VERSION:0:1}_${CPANEL_PHP_VERSION:1}"

#if $BIN/v-list-web-templates-backend | grep -qw "$HESTIA_PHP_VERSION"; then
#    echo "Setting PHP version to $HESTIA_PHP_VERSION for $main_domain1 under user #$new_user"
#    $BIN/v-change-web-domain-backend-tpl $new_user $main_domain1 $HESTIA_PHP_VERSION
#    if [ $? -ne 0 ]; then
#        echo "Failed to set PHP version for $main_domain1"
#        exit 1
#    else
#        echo "PHP version for $main_domain1 set to $HESTIA_PHP_VERSION"
#    fi
#else
#    echo "PHP version $HESTIA_PHP_VERSION is not installed on HestiaCP."
#    echo "Please install it before trying to set it for a domain."
#    exit 1
#fi

##################

3.- Try to import the backup again.

1 Like

Hi @sahsanu yes they exist, could it be an issue that I have a addon domain also?

I will have a go commenting out those sections of the script and see how I go.

@sahsanu it looks like the script only loads the main domain and ignores the addon domain which causes all my emails on the addon domain fail to imports etc Looks like it restores the main domain but skips the addon domain

This is the code that takes care of addon domains:

addon_domains=$(cat addons | cut -d "=" -f1)
sed -i 's/_/./g; s/=/ /g' addons
echo "Converting addons domains, subdomains and some other fun"
cp sds hst_sds
cp sds2 hst_sds2
sed -i 's/_/./g' hst_sds
cat addons | while read ddon_domain addon_sub; do
        echo "Converting default subdomain: $addon_sub in domain: $addon_domain"
        sed -i -e "s/$addon_sub/$addon_domain/g" hst_sds
        sed -i -e "s/$addon_sub/$addon_domain/g" hst_sds2
        mv userdata/$addon_sub userdata/${addon_domain}
done
sed -i 's/public_html/public@html/g; s/_/./g; s/public@html/public_html/g; s/=/ /g' hst_sds2

But as I said, I can’t help here because I know nothing about CPanel and its backups :frowning:

Hi @sahsanu how are addon domains done in hestia? I only see option to add another web domain, I tried to add it manually, but there is no option to set it as an addon domain or anything?

I’ve no idea what an addon domain is. In Hestia you can create as many domains as you want (if the package allows it) and you can add alias to those domains.

@sahsanu I see it is treated as just another domain with hestia which is no problem and just have to manually do the redirects etc see links for what is referred to as addon domain.

https://www.bluehost.com/help/article/difference-between-addon-parked-and-subdomains

The emails imported on my main domain and show the disk space and accounts but if I go into the mail folder using the file explorer the folder is empty? where does hestia store the emails for that user or domain?

If I ssh directly into my server and look under that user and mail, all the domains are there including all the email accounts for both domains and the mail content etc it seems there may be an issue with the file explorer? Why is hestia not seeing these and adding them to the system?

Ok, it is like add a new domain or sub domain.

mail and conf/{dns,mail,web} dirs are using resticted perms so you won’t be able to look inside from file manager.

Hi @sahsanu since all the contents are there, why is hestia not seeing the email accounts for the other domain, I manually added the domain and enabled mail and all the content is in the mail folder under the correct domain. I rebooted the server just incase and still can’t find those email accounts for that domain, is there another way I need make hestia see them?

Sorry but I don’t understand what you mean. Did you add your web domain and mail domain manually and then imported the backup or you imported your backup and then added manually your web domain and mail domain?

@sahsanu during to original import, it imported all the files for both domains, just didn’t add the second domain to hestia, so I have added the second domain my self manually hoping it would automatically see all the email accounts and files in the Mail folder, but it does not show up in the hestia control panel, they are missing.

if the email accounts were not created during the import, then Hestia will not see them.

Okay I see, If I was to run v-rebuild-mail-domain username domain.com would this do this trick or do I have to also change the $HESTIA/data/users/username/mail.conf?

Maybe I’m best to try reimport again and hopefully the script adds the second domain this time so it can be done correctly