Question php script to create websites

Discussion in 'Plesk 10.x for Windows Issues, Fixes, How-To' started by thomasvestergaard, Dec 26, 2016.

  1. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    Hello

    I use plesks 10.4.4 and would like to know if i can create websites with a php script?

    Today i create them manually but the amount of sites i create is getting more and more and would like to automate the process.

    I know nothing of plesks api so any help is appreciated

    Regards
    Thomas
     
  2. IgorG

    IgorG Forums Analyst Plesk Team

    43
    84%
    Joined:
    Oct 27, 2009
    Messages:
    22,949
    Likes Received:
    755
    Location:
    Novosibirsk, Russia
  3. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    Thankyou IgorG

    Is there any guides to be found about how to create a new website with the plesk XML RPC?
     
  4. IgorG

    IgorG Forums Analyst Plesk Team

    43
    84%
    Joined:
    Oct 27, 2009
    Messages:
    22,949
    Likes Received:
    755
    Location:
    Novosibirsk, Russia
    Use this guide - Managing Sites (Domains)
     
  5. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    Thank you IgorG

    Is there any php examples because i really don't know where to begin with that information?
     
  6. IgorG

    IgorG Forums Analyst Plesk Team

    43
    84%
    Joined:
    Oct 27, 2009
    Messages:
    22,949
    Likes Received:
    755
    Location:
    Novosibirsk, Russia
    What about this example PHP Client Application ?
     
  7. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    My problem is that i don't know how to call "create website" and how to set all of the parametres that is avaliable. I'm looking for a easy to follow guide in php?
     
  8. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    I now have access to get all domains and see som info.

    1. But in this add excample how do i know what to set in webspace-id, can i leave it blank and it will autocreate a unik id?
    2. How do i enable "Microsoft ASP support "
    3. How do i enable "Custom error documents "
    4. How do i enable " Additional write/modify permissions "
    5. How do i switch Web statistics to "Webalizer" and check the checkbox in "accessible via password-protected directory '/plesk-stat/webstat/"

    <packet version="1.6.3.0">
    <site>
    <add>
    <gen_setup>
    <name>sample.com</name>
    <webspace-id>13</webspace-id>
    </gen_setup>
    <hosting>
    <vrt_hst>
    <property>
    <name>fastcgi</name>
    <value>true</value>
    </property>
    <property>
    <name>php</name>
    <value>true</value>
    </property>
    </vrt_hst>
    </hosting>
    </add>
    </site>
    </packet>
     
  9. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    I now have this php code, but have no idear how to move on

    function addNewSite()
    {
    $xmldoc = new DomDocument('1.0', 'UTF-8');
    $xmldoc->formatOutput = true;

    // <packet>
    $packet = $xmldoc->createElement('packet');
    $packet->setAttribute('version', '1.6.3.0');
    $xmldoc->appendChild($packet);

    // <packet/site>
    $site = $xmldoc->createElement('site');
    $packet->appendChild($site);

    // <packet/domain/add>
    $add = $xmldoc->createElement('add');
    $domain->appendChild($add);

    // <packet/domain/get/gen_setup>
    $gen_setupTmp = $xmldoc->createElement('gen_setup');
    $get->appendChild($gen_setupTmp);

    // dataset elements
    $gen_setupTmp->appendChild($xmldoc->createElement('name'));
    $gen_setupTmp->appendChild($xmldoc->createElement('webspace-id'));



    return $xmldoc;
    }
     
  10. thomasvestergaard

    thomasvestergaard New Pleskian

    2
    70%
    Joined:
    Dec 26, 2016
    Messages:
    7
    Likes Received:
    0
    Location:
    Denmark
    And what about these,

    • webspace-name, required
      It defines the name of a subscription to which the Panel will assign a new site. Data type: string.

    • webspace-id, required
      It defines the ID of a subscription to which the Panel will assign a new site. Data type: string.

    • webspace-guid, required
      It defines the GUID of a subscription to which the Panel will assign a new site. Data type: string
     
  11. IgorG

    IgorG Forums Analyst Plesk Team

    43
    84%
    Joined:
    Oct 27, 2009
    Messages:
    22,949
    Likes Received:
    755
    Location:
    Novosibirsk, Russia
    Sorry, I'm not PHP developer. I have given you all available documentation and direction. Then you, as a PHP developer, can sort it out by yourself, I think.
     
Loading...