Newly cloned domain already exists.

I have this PHP script calling the clone-domain program of the remote API:

<?php
    $result = shell_exec("wget -O - --quiet --http-user=username --http-passwd=password --no-check-certificate 'https://localhost:10000/virtual-server/remote.cgi?program=clone-domain&domain=first.domain.com&newdomain=second.domain.com");

    print_r($result);
?>

The domain 'second.domain.com' does not exist on the server, and the domain 'first.domain.com' is successfully cloned to the domain 'second.domain.com'. But this error message is displayed:

A virtual server named second.domain.com already exists

I want to make a simple PHP page to easily clone an existing domain on the server. Getting this wrong error message, makes it impossible to give feedback to the user when the cloning is successful.

Thank you for your input.

Status: 
Closed (fixed)

Comments

Howdy -- hmm, is it possible that your script is being called twice? So that the clone-domain is actually working when running the first time, but generating the error you mentioned during the second run?

You can also test to see if this happens from the command line, by running the following command as root :

virtualmin clone-domain --domain firstdomain.com --newdomain seconddomain.com

Running clone-domain from the command line works fine; the domain is cloned successfully and the output messages are the same as is displayed when cloning using the virtualmin system.

I get the error when running the script from any browser, but i can only see one request to the server. And calling list-domains from the browser works, and gives me the list of domains correctly.

I have checked the apache logs.

Only one entry is made in the access log when requesting the script using a browser.

This message is logged in the error log:

[Fri Feb 28 09:31:59 2014] [emerg] [client 31.185.67.20] (22)Invalid argument: mod_fcgid: can't lock process table in pid 24654

Do you see different results if you change the PHP Execution Mode for the domain that has the PHP script?

You can do that by going into Server Configuration -> Website Options, and there, change the PHP Execution Mode to "CGI".

I changed the PHP Execution Mode to "CGI", ran the script and got the correct success message from virtualmin.

Thanks a lot for the help :)