1,105,585 Community Members

Restart Apache server through php

Member Avatar
DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
vibhaJ
Posting Shark
960 posts since Apr 2010
Reputation Points: 126 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 3 [?]
 
1
 

I haven't tried but exec may help you.

exec('/etc/init.d/httpd graceful');
Member Avatar
DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Pro2000
Posting Whiz
351 posts since Jun 2007
Reputation Points: 29 [?]
Q&As Helped to Solve: 26 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
DILO3D
Newbie Poster
21 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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 ?

Member Avatar
Pro2000
Posting Whiz
351 posts since Jun 2007
Reputation Points: 29 [?]
Q&As Helped to Solve: 26 [?]
Skill Endorsements: 0 [?]
 
1
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: