I am trying to create a domain on a plesk server from a php script.
I have this...
exec('plesk bin domain -c booking.test.com -webspace-name dev-us2.test.com -dns false -mail_service false -www-root httpdocs', $response);
var_dump($response);
Which outputs this....
array(1) { [0]=> string(24) "Error: must run as root." }
I have also tried running it with "sudo" in front - but I just get a blank array returned.
Is there a way for me to run this securely, or at least be able to view an error log to work out where im going wrong?
EDIT:
I have now tried adding it into a shell script....
#!/usr/bin/env bash
error() {
echo "$@" 1>&2
}
fail() {
error "$@"
exit 1
}
URLBASE=${1?Error: no url given}
SERVER=${2?Error: no server given}
plesk bin domain -c $URLBASE -webspace-name $SERVER -dns false -mail_service false -www-root httpdocs
If i run the script as root through SSH it works, but if I try and execute it from the PHP file, it has the same "must run as root" error.
Ive tried adding the user and script to sudoer Ive tried adding the user to the sudoer.d/ directory Ive tried changing the owner of the script - but still nothing.