我需要使用Plesk API创建域。一切正常,直到我添加'托管'参数。
没有'托管'
$request_create_domain = <<<EOF
<packet>
<site>
<add>
<gen_setup>
<name>example.com</name>
</gen_setup>
</add>
</site>
</packet>
EOF;
托管。我收到内部服务器错误。它仍然创建一个域,但不再执行完整的PHP脚本。
$request_create_domain = <<<EOF
<packet>
<site>
<add>
<gen_setup>
<name>example.com</name>
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>www_root</name>
<value>/sample</value>
</property>
</vrt_hst>
</hosting>
</add>
</site>
</packet>
EOF;
该网站运行PHP7.1作为Apache提供的FastCGI应用程序。通过CLI执行脚本会给我带来这个错误。
An incorrect PHP handler ID was specified. The following values are possible for php_handler_id: fastcgi, fpm, plesk-php71-fastcgi
完整的脚本:
require 'class.plesk.php';
$plesk_client = new PleskApiClient('0.0.0.0');
$plesk_client->setCredentials('...', '...');
$request_create_domain = <<<EOF
<packet>
<site>
<add>
<gen_setup>
<name>berryvandervelden.nl</name>
<webspace-id>2</webspace-id>:
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>www_root</name>
<value>/berryvandervelden</value>
</property>
</vrt_hst>
</hosting>
</add>
</site>
</packet>
EOF;
$response = $plesk_client->request($request_create_domain);
$answer_created_domain = simplexml_load_string($response);
if ($answer_created_domain->site->add->result->status == 'ok') {
// Send mail.
}
答案 0 :(得分:1)
我很确定你的错误500不是来自Plesk而是来自脚本。如果可以,请分享完整的PHP脚本。
对于API请求,您忘记了<webspace-id>N</webspace-id>
:
<packet>
<site>
<add>
<gen_setup>
<name>example.com</name>
<webspace-id>3</webspace-id>
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>www_root</name>
<value>/sample</value>
</property>
</vrt_hst>
</hosting>
</add>
</site>
</packet>
实际上脚本对我有用:
<?php
require 'class.plesk.php';
$plesk_client = new PleskApiClient('127.0.0.1');
$plesk_client->setCredentials('admin', 'setup');
$request_create_domain = <<<EOF
<packet>
<site>
<add>
<gen_setup>
<name>example2.com</name>
<webspace-id>3</webspace-id>
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>www_root</name>
<value>/sample</value>
</property>
</vrt_hst>
</hosting>
</add>
</site>
</packet>
EOF;
$response = $plesk_client->request($request_create_domain);
var_dump($response);
$answer_created_domain = simplexml_load_string($response);
if ($answer_created_domain->site->add->result->status == 'ok') {
// Send mail.
}