As part of the signup process on our site, VirtualHost directives get created an added to a config file via PHP, after each VirtualHost is created apache is restarted gracefully so that the new site starts working. The user PHP which runs under (www) was given permission to restart apache in /etc/sudoer and then a php script called exec('/usr/local/bin/sudo /usr/local/sbin/apachectl graceful');
This works perfectly. However we're in the process of moving to a new server and I cant get this working at all on the new setup
Ive added the following line to /etc/sudoers
apache ALL= NOPASSWD: /usr/sbin/apachectl graceful
and then our PHP script calls:
exec('/usr/bin/sudo /usr/sbin/apachectl graceful');
If I enable shell access for the apache user and login I can run 'sudo /usr/sbin/apachectl graceful' perfectly fine, its just when we call it from PHP it doesnt work.
Has anybody got any ideas? Thanks.
On our old FreeBSD server we were running Apache 1.3.x and PHP 4.4
Our new server is CentOS 5.4 w/ Apache 2.2.x and PHP 5.3.2