954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Restart Apache server through php

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.

DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I haven't tried but exec may help you.

exec('/etc/init.d/httpd graceful');
vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

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

DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

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.

Pro2000
Posting Whiz
351 posts since Jun 2007
Reputation Points: 44
Solved Threads: 23
 

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 ?

DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I don't know whether these functions can also be disabled by the server administrator.
You can refer to the manual of PHP:
http://www.php.net/manual/en/ref.exec.php

Pro2000
Posting Whiz
351 posts since Jun 2007
Reputation Points: 44
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: