reload apache from a php script

General support questions
Post Reply
hercent
Posts: 2
Joined: 2013/01/11 22:50:50
Contact:

reload apache from a php script

Post by hercent » 2013/01/11 22:56:13

Hello,

sorry for the maybe dumb question but I'm new to centos 6.
I had a linux vps and an app that uses simple php command:
exec('/etc/init.d/httpd reload');
It worked fine on the vps but now moved to centos 6 and it wont work.
I-ve checked and selinux is disabled, so I'm clueless.

I;ve added

apache ALL=(ALL:ALL) NOPASSWD: ALL

to /etc/sudoers

I know the above may seem something horrible to most of you but I really want apache user to be able to reload httpd.

Any help greatly appreciated.

hercent
Posts: 2
Joined: 2013/01/11 22:50:50
Contact:

Re: reload apache from a php script

Post by hercent » 2013/01/12 02:14:50

I just was able to fix this.
Actually php exec('whoami') was working but the httpd command was not. So after allowing apache to run commands with visudo and then ##Defaults requiretty (commenting out this line) and creating a sh script that only reload 'graceful' httpd it worked finally.

thanks anyway,

Post Reply