1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

how to run subdomain.sh from PHP

Discussion in 'Plesk for Linux - 8.x and Older' started by deem7, Jul 9, 2005.

  1. deem7

    deem7 Guest

    I'm trying to create/delete subdomains from a PHP script (executed from web). Until now all my attempts have failed :(

    (AFAIK there is no way to create/delete subdomains through the sdk api?)

    I tried sudo and it didn't work. I wrote a C program which run subdomain.sh, and gave it root uid and gid and it doesn't work either.

    Is there any special protection in subdomain.sh against being called from web?

    How to overcome it?
  2. deem7

    deem7 Guest

    Ok, problem solved :)
    sudo and C program were OK, my problem was somewhere else.
  3. bcstaat

    bcstaat Guest

    Hoping you are still around. I am having a sitution where sudo command line from php is not working. Apache id is being blocked from running the command from what I can tell. Is this what you experienced? What was your solution?
  4. deem7

    deem7 Guest

    Hi, I don't know what can be the cause of your problem. In my case everything worked fine but the Plesk script printed everything to strerr instead to stdout. So the php command "system()" returned nothing and I thought it didn't work.

    All I can do is to give you my current configuration which works:

    file /etc/sudoers - add line:
    apache ALL= NOPASSWD: /usr/local/psa/bin/subdomain.sh

    and this is what I run from php:
    system("/usr/bin/sudo /usr/local/psa/bin/subdomain.sh -c $subdomain -d $domain -ftp_user native -lo
    gin $subdomain -passwd $password -php true 2>&1");

    this creates a subdomain with given parameters.

    best regards
  5. bcstaat

    bcstaat Guest

    thank you for the reply I will apply it if necessary.