• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

how to run subdomain.sh from PHP

D

deem7

Guest
HI,
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?
 
Ok, problem solved :)
sudo and C program were OK, my problem was somewhere else.
 
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?
 
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
deem
 
Back
Top