I'm trying to use vpopmail's vadddomain
to add new virtual domains. Since apache
user has no access to vpopmail's binaries I cannot exec('../bin/vadddomain...')
directly from PHP.
I made a shell script (adddomain.sh
) as below:
#!/bin/bash
cd /home/lxadmin/mail/bin
./vadddomain $1 postmaster_password
And appended this line to /etc/sudoers
using visudo
(forget about security for now):
ALL ALL=NOPASSWD: /home/lxadmin/mail/bin/adddomain.sh
I have something like this in my PHP script:
exec('sudo /home/lxadmin/mail/bin/adddomain.sh example.com', $output);
But this is not working at all (domain example.com
will not be added to vpopmail).
But when I run this command through SSH and with root user, it works.
Can anyone tell what is my problem here?