skip to Main Content

I have a script wich uses the Plesk API to create FTP accounts. The script worked perfectly untill we moved to new VPS at a new provider.

The script doesnt work anymore and I get an error like this:

cURL error number:7 cURL error:Failed to connect to xx.xx.xxx.xxx permission denied.

It seems that cURL doesnt work. What i’ve tried is changing the php support from fastCGI to Apache module in PLESK and the error message is gone but the PLESK API does nothing though the load time of the page is much longer then when I’m using fastCGI so it looks like it does something.

I also added port 8443 to the firewall for incoming and outgoing.

I’m using PLESK 11 and my script looks like this.

// Plesk login gegevens
$host   = "**********";
$login  = "**********";
$pass   = "**********";
$port   = 8443;


// Maak de FTP map aan
$data =<<<EOF
<packet version="1.6.3.5">
<ftp-user>
<add>
<name>John</name>
<password>Doe1234</password>
<home>/private/John_Doe/</home>
<create-non-existent>true</create-non-existent>
<webspace-id>1</webspace-id>
</add>
</ftp-user>
</packet>

EOF;

sendCommand($data, $login, $pass, $host, $port);

function write_callback($ch, $data) 
{
    // echo $data;
    return strlen($data);
}

function sendCommand($data, $login, $passwd, $host, $port=8443) 
{
    echo $data;

    $script = "enterprise/control/agent.php";
    $url = "https://$host:$port/$script";
    $headers = array(
    "HTTP_AUTH_LOGIN: $login",
    "HTTP_AUTH_PASSWD: $passwd",
    "HTTP_PRETTY_PRINT: TRUE",
    "Content-Type: text/xml",
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, &$headers);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'write_callback');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    $result = curl_exec($ch);

    if (!$result) 
    {
         echo "nn-------------------------ncURL error number:".curl_errno($ch);
         echo "nncURL error:".curl_error($ch);
    }

    curl_close($ch);
    return;
}

3

Answers


  1. I am not plesk or linux person, But i would like to contribute my part with this discussion,

    I have a script wich uses the Plesk API to create FTP accounts. The
    script worked perfectly untill we moved to new VPS at a new provider.

    This statement clearly says problem is not your code, It’s with your VPS.

    Problem maybe!

    1) Client permission to update Parallels Panel via API-RPC, try with admin credentials.

    Issue found : plesk 9.2. So it may be fixed in next release but i am not sure. Source

    2) Check SElinux is disabled or not, if not disable it and check. Your next question must be, how to disable SElinux. Answer is here well documented

    3) You should install mod_suphp and follow our tutorial and will work. Check out here for more.

    I just above summarized, few thinks hope it helps.

    Login or Signup to reply.
  2. i am not sure but see below URL I think it is very help full to you.

    Unusual HTTP headers in the Plesk API

    According to Unusual HTTP headers in the Plesk API by TRiG

    Or Read it

    Below Answer by rdo according to above URL

    1. Plesk uses own headers. In custom http request you can add any valid headers for example some webservers add own header like ‘powered by: xxxx’, so it’s ok.

    2. pretty print header is required for pretty xml output.

    3. HTTP_AUTH_LOGIN header contains panel user login. HTTP_AUTH_PASSWD header contains panel user password. CURLOPT_USERPWD is not required.

    4. try to use these options: $ch = curl_init();

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

      curl_setopt($ch, CURLOPT_URL, $url);

      curl_setopt($ch, CURLOPT_ENCODING, ‘UTF-8’);

      curl_setopt($ch, CURLOPT_POSTFIELDS, $packet);

      curl_setopt($ch, CURLOPT_TIMEOUT, 1200); //wait 20min

      $response = curl_exec($ch);

    Login or Signup to reply.
  3. Assuming you remembered to change the host, was your plesk user and password recreated after the move? Try logging into plesk on the VPS directly using the credentials from your script to make sure the account is ok.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search