Submitted by anders_fairweb on Thu, 02/27/2014 - 09:49
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
Submitted by andreychek on Thu, 02/27/2014 - 10:23 Comment #1
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?
Submitted by JamieCameron on Thu, 02/27/2014 - 16:45 Comment #2
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
Submitted by anders_fairweb on Fri, 02/28/2014 - 02:23 Comment #3
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.
Submitted by anders_fairweb on Fri, 02/28/2014 - 03:00 Comment #4
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
Submitted by andreychek on Fri, 02/28/2014 - 09:50 Comment #5
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".
Submitted by anders_fairweb on Fri, 02/28/2014 - 10:03 Comment #6
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 :)