Trying to start VPNC from PHP exec()
Question
I am trying to start my VPN connection (using VPNC) from PHP. I have to do it this way because it is closed remotely if there isn't activity so I can't just leave it running on the server. I am able to do it from the command line by typing:
/usr/local/sbin/vpnc --natt-mode force-natt
This works. It doesn't require any input from me because I'm storing the password in it's conf file. This does not work from PHP:
exec('/usr/local/sbin/vpnc --natt-mode force-natt', $output, $result);
echo $result.',';
print_r($output);
The output is:
1,Array
(
)
Safe mode is off, the "/usr/local/sbin" directory is allowed via open_basedir, and vpnc is executable by all users. Any ideas why I can't get the VPN connection going this way?
Solution
Turned out the problem was needing to call it using "sudo." VPNC has to be called from root. I've posted more info here: http://bkwld.com/blog/2009/10/vpn-through-php-on-mt/