I`m trying to offer free hosting with Virtualmin and i want to create a PHP script that will create a new top level domain / administration username .
The only way i can do it is by using shell_exec() and this URL:
but it gives me one big problem, the administration username is not created. The administration username is vuser_def=1 (automatic) in the above URL, but still i get this error:
Failed to create virtual server : Mail for the domain cannot be enabled unless an administration user is created
How can i fix this, or can you guide my to a bether way to create new domains/users by user imput with PHP?
You should make use of the “remote” or “cli” API.
To create a domain via the “remote” API, make a call to:
*** above is a minimal example which will output to your script a JSON response ***
For more information visit the following pages.
Virtualmin CLI API:
Virtualmin Remote API
Thanks for the replay.
I want to create a HTML form where the user will input only the desired domain name, domain description and password. A php script will collect this info and will use Virtualmin CLI or PHP API to execute the command to create a new user with a toplevel domain, but how can i do this with Virtualim CLI? How to execute the CLI command from a PHP script that collects the data from my HTML form ?
You’d use the above “remote.cgi” script on the backend of your script… For instance when the person clicks “submit” on your form, after going through whatever form validation you have setup, you’d eventually issue something like:
*** the above uses the “exec” command from PHP as an example ***
If you require a more complex method of accomplishing this task, I am available at a rate of $40.00/hr. to offer web development.
As noted above, you should refer to the CLI/Remote API documentation for all the available options which can be passed to the API.
Okay, how much do i have to pay for this:
A HTML form where the user inserts only domain name, password and contact email
A php script that collects the data from the form and executes the Virtualmin Remote API and creates a new toplevel domain for that user, like $domain = $_POST[“domain”]; $pass = $_POST[“pass”]; $contact_email = $_POST[“c_email”];
I dont want the user to specify a username, i want Virtualmin to automatically create a administration username from the domain name, like if domain is = abcdownload.ro , administration username will be abcdownload
Can you do this for me ?
Drop me an email, and we can work out a reasonable deal, don’t worry I don’t bite
I have a problem with --web parameter, witch is if the --web parameter is present in the LINK structure, Virtualmin will not create the Administration username and domain creation will fail with Exit status: 256 : A website cannot be enabled without an administration user , LINK user was: 192.168.1.101:firstname.lastname@example.org&web&dns&logrotate&mysql&webmin - notice that the web parameter was included in the link.
If i use the same LINK but without the --web parameter, Virtualmin will create the Administration username, domain, webmin login, dns and other settings, but the domain is not active on the Virtualmin server because the --web parameter is not present in the LINK -> 192.168.1.101:email@example.com&dns&logrotate&mysql&webmin
Is this a bug, or i`m doing something wrong.
I finally figured out what was wrong:
from my URL was missing this parameters: --unix (for creating the user) and --dir (for home dire creation)
It work great now
Please show an example of your complete cgi code. I am also having the same problem as you but I cannot follow your solution
This is my working code:
See the file hosting.txt, you can upload it to your server and give it a try. Change the root password and the virtualmin server hostname and port., and rename the file to hosting.php .
Im curious about this as well, as i am planning on rolling out free web hosting as well. I am not seeing the text file mentioned? would be cool to take a gander and see if I could implement this onto my server.