Results 1 to 6 of 6

Thread: Subdomains Through The PHP SCRIPT ?

  1. #1
    Join Date
    Jan 2012
    Posts
    1

    Subdomains Through The PHP SCRIPT ?

    Dear All ,

    I want to make sub-domains using php scripts . Means i dont want use control panel .
    I want help from you guys .

    Thanks in advance from my heart.


    Awaiting your response.

    Thanks and Regards
    Jai

  2. #2
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    6,641
    You can use PHP API (search on the forum)

    here the one for subdomain:

    Code:
    <?php
    
    include 'httpsocket.php';
    
    $sock = new HTTPSocket;
    $sock->connect('localhost',2222);
    
    $sock->set_login("admin|user","admin_password");
    
    $sock->set_method('POST');
    
    $sock->query('/CMD_API_SUBDOMAINS',
            array(
                    'action' => 'create',
                    'domain' => 'MAINDOMAIN',
                    'subdomain' => 'SUBDOMAIN_NAME',
                    'create' => 'Create'
        ));
    
    $result = $sock->fetch_body();
    
    ?>
    Hope it help.

    Regards
    SeLLeRoNe - Andrea Iannucci
    DevOps Engineer - System Administrator
    If you need my support write me an E-Mail to Support@CrazyNetwork.it

  3. #3
    Join Date
    Oct 2015
    Posts
    22
    Hi everyone,

    I want to create a php script to my client which allow to create a subdomain from wordpress. But I have problem in first step. This is my code:
    Code:
    <?php
    
    include 'httpsocket.php';
    
    $sock = new HTTPSocket;
    $sock->connect('127.0.0.1',2222);
    
    $sock->set_login("admin","password");
    
    $sock->set_method('POST');
    
    $sock->query('/CMD_SUBDOMAIN',array( 'action' => 'create',
    'domain' => 'directadmin.pl', 'subdomain' => 'test.directadmin.pl' ));
    
    
    ?>
    No error no results in directadmin. What is wrong ?

    Kind regards

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Hello,

    There might be numerous reasons on that. Then it should be "admin|user" where both admin and user should present (of course you should replace admin with a real name of your re-seller if it differs from admin and replace user with a real name of domain's owner).

    p.s. You missing:

    PHP Code:
    $result $sock->fetch_body(); 
    update it with:


    PHP Code:
    $result $sock->fetch_body();
    var_dump($result); 
    to see results.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  5. #5
    Join Date
    Oct 2015
    Posts
    22
    I have another problem. Let say I create a php script under directadmin.com domain. When I run that script a subdomain ex. php.directadmin.com is create in /home/user/domains/directadmin.com not in /home/user/domains/php.directadmin.com why ?

    Kind regards

  6. #6
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    That's how Directadmin works. Add a sub-domain as a regular domain if you want a separate public_html directory.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

Similar Threads

  1. Actual Subdomains and Wildcard Subdomains
    By Fatty in forum Apache (WWW)
    Replies: 4
    Last Post: 08-06-2011, 07:15 AM
  2. Automatic subdomains and manually created subdomains
    By mvdg27 in forum Admin-Level Difficulties
    Replies: 0
    Last Post: 12-11-2007, 03:56 PM
  3. Execute mySql script from within php script
    By mesmo in forum MySQL / PHP
    Replies: 1
    Last Post: 10-19-2007, 07:16 PM
  4. script makes subdomains
    By Tom13 in forum DirectAdmin General Discussion
    Replies: 0
    Last Post: 10-14-2005, 08:15 AM
  5. Replies: 12
    Last Post: 10-28-2004, 01:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •