Page 1 of 1

WHMCS | VestaCP Module | Unable to create sub domains.

Posted: Mon Sep 14, 2015 7:26 pm
by TopeZ
As I use the WHMCS | VestaCP Module, I want to offer free sub domains for the members of my community.

Looking at the WHMCS VestaCP module; it seems that it doesn't support this feature at all. It's only utilized for creating new accounts with the purchase of a domain entirely. While that works perfectly fine so far. There is nothing for sub domain creation for an account already created in VestaCP.

Code: Select all

        // Add domain
        if(($answer == 'OK') && (!empty($params["domain"]))) {
            $postvars = array(
              'user' => $params["serverusername"],
              'password' => $params["serverpassword"],
              'hash' => $params["serveraccesshash"],
              'cmd' => 'v-add-domain',
              'arg1' => $params["username"],
              'arg2' => $params["domain"],
              'arg3' => $params["configoption3"],
            );
            $postdata = http_build_query($postvars);
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, 'https://' . $params["serverhostname"] . ':8083/api/');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
            $answer = curl_exec($curl);

            logModuleCall('vesta','CreateAccount_AddDomain','https://'.$params["serverhostname"].':8083/api/'.$postdata,$answer);
        }
Now I see the cmd/CLI for "v-add-domain" but I fear I don't see a cmd for creating sub domains looking over the CLIs for VestaCP unless I'm overlooking something. Is this even possible without having a cmd for creating sub domains to be added in the Module?

Any help would be appreciated! Much thanks VestaCP! I love the work so far, loved the new update, and I've learned so much so much because of VestaCP so far! :)

Re: WHMCS | VestaCP Module | Unable to create sub domains.

Posted: Mon Sep 14, 2015 10:39 pm
by SCelik
There is no extra command for adding subdomains. You have to add like a domain.

Don't forget to disable dns support while adding subdomain. And add a A Record for subdomain on main domain.

Maybe on next releases, there will be subdomain add command. And also protecting for addin subdomains on other accounts/domains. Any user can add any subdomain for domains hosted on same server. No matter they own domain or not.

Re: WHMCS | VestaCP Module | Unable to create sub domains.

Posted: Sat Oct 24, 2015 3:23 pm
by mike08
Hey TopeZ,

I hope you have found a way to do this, since there isn't any reply in a long time I'll go ahead and add some steps on how you can success to create free subdomains either you or someone else that is looking for this.

Actually this is not a vestacp feature or issue all you have to do is setup WHMCS in a proper way:

Go to Setup ---> Product/Services ---> Product/Services ---> Choose the web hosting package that you want to have a free subdomain ---> Click on Other tab ---> and edit the 3rd option which is Subdomain Options and add your domain in this format:

Code: Select all

.mycoolname.xyz
---> Then save the changes ---> Now on your VestaCP add the following A record.

Code: Select all

*     A    Your_Server's_main_IP
In this way whenever the subdomain is created by the API you don't have to create an A record (Even though at the moment anyone can create subdomains on behalf others that you can fix it in some simple steps or so viewtopic.php?f=13&t=9175)

Hope this helps, regards.

Re: WHMCS | VestaCP Module | Unable to create sub domains.

Posted: Wed Feb 17, 2016 9:42 am
by TopeZ
Thanks Mike, nope I decided to skip it but I'll try revisiting it and see if this works!

Looks like I have an entirely different issue with WHMCS now it seems...