Can anyone tell me, How can i restart the apache server through php code?


if i view a specific page,my apache server should be automatically restart.
How can i perform this?

Anybody Please help me.

I haven't tried but exec may help you.

exec('/etc/init.d/httpd graceful');

It is not working. do i need to give some permission to system files? i m using linux.

Why would you do that??
You may find a better solution to your problem if you tell us about it.
Also, if you're running your program on the internet, the server administrator must have banned changing the status of Apache.. That's, of course, because the server, mostly, has more than one website hosted on it... So restarting Apache on the server will mostly cause a problem to the other websites operating on that very server.

i just pointed apache as a example. Really i have to restart a application (it is smokeping) . evry time if i change the configuration file i have to restart manually.

so i need to have auto restart.
Is there any way to restart through php codes? i tried exec(),shell_exec(),system().
they are not working.

Any solutions plz ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.