• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Question php script to create websites

thomasvestergaard

New Pleskian
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
 
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?
 
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>
 
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;
}
 
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
 
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.
 
Back
Top