Jump to content


Photo

Restart Apcahe


  • Please log in to reply
8 replies to this topic

#1 ishan

ishan
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 16 November 2005 - 01:02 PM

I am wondring if there is any possiblety to restart apache service with only php from a remote host...

//Ishan Jain

#2 neylitalo

neylitalo
  • Staff Alumni
  • Advanced Member
  • 1,854 posts
  • LocationMichigan, USA

Posted 16 November 2005 - 01:15 PM

I highly doubt it - you could make a system call on the server you want to restart it on, but I don't know how Apache would react to being shutdown by one of it's processes :x

<?php

exec("/usr/local/apache2/bin/apachectl restart");

?>

would do it for most custom compilations of Apache, if it would work. That would be the command to use.

Assuming your server is running Linux.
http://nealylitalo.net - My personal website, and home of The Netizen's Journal.

#3 ishan

ishan
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 21 November 2005 - 10:11 AM

I am using apache on Windows. I can stop apache service with command "net stop Apache2" but it would not start afterwards...

[!--quoteo(post=319097:date=Nov 16 2005, 02:15 PM:name=neylitalo)--][div class=\'quotetop\']QUOTE(neylitalo @ Nov 16 2005, 02:15 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I highly doubt it - you could make a system call on the server you want to restart it on, but I don't know how Apache would react to being shutdown by one of it's processes :x

<?php

exec("/usr/local/apache2/bin/apachectl restart");

?>

would do it for most custom compilations of Apache, if it would work. That would be the command to use.

Assuming your server is running Linux.
[/quote]


#4 lilcam

lilcam
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 November 2005 - 04:01 PM

[!--quoteo(post=320634:date=Nov 21 2005, 05:11 AM:name=Ishan Jain)--][div class=\'quotetop\']QUOTE(Ishan Jain @ Nov 21 2005, 05:11 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I am using apache on Windows. I can stop apache service with command "net stop Apache2" but it would not start afterwards...
[/quote]

Why can't you start it with "net start Apache2"

#5 ishan

ishan
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 22 November 2005 - 10:17 AM

[!--quoteo(post=320721:date=Nov 21 2005, 05:01 PM:name=lilcam)--][div class=\'quotetop\']QUOTE(lilcam @ Nov 21 2005, 05:01 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Why can't you start it with "net start Apache2"
[/quote]

Once server is down it will not execute php any futher....
and with "net stop Apache2" it is gone and script is gone.

#6 haydndup

haydndup
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationJohannesburg, South Africa

Posted 22 November 2005 - 01:08 PM

You could get PHP to execute a batch file...

The batch file code would be:

net stop Apache2
net start Apache2

Then execute the batch file. It should continue running even when Apache is down
[!--coloro:#660000--][span style="color:#660000"][!--/coloro--]The Gene Pool Could Use A Little Chlorine[!--colorc--][/span][!--/colorc--]

#7 ishan

ishan
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 22 November 2005 - 01:11 PM

[!--quoteo(post=321069:date=Nov 22 2005, 02:08 PM:name=WhyWindows)--][div class=\'quotetop\']QUOTE(WhyWindows @ Nov 22 2005, 02:08 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You could get PHP to execute a batch file...

The batch file code would be:

net stop Apache2
net start Apache2

Then execute the batch file. It should continue running even when Apache is down
[/quote]
It should but my server just ignores all the executable files and commands exept the basc ones in the Command Promopt

#8 haydndup

haydndup
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationJohannesburg, South Africa

Posted 22 November 2005 - 07:44 PM

[!--quoteo(post=321071:date=Nov 22 2005, 03:11 PM:name=Ishan Jain)--][div class=\'quotetop\']QUOTE(Ishan Jain @ Nov 22 2005, 03:11 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
It should but my server just ignores all the executable files and commands exept the basc ones in the Command Promopt
[/quote]

You could try a more extreme option - restart the entire server itself?
But you won't be able to do that if more than one site is being hosted on the pc - if its a dedicated server, it shouldn't be a problem, just use:

shutdown -r -f -t 00

This will make the pc restart immediately, forcing all services to stop.
[!--coloro:#660000--][span style="color:#660000"][!--/coloro--]The Gene Pool Could Use A Little Chlorine[!--colorc--][/span][!--/colorc--]

#9 ishan

ishan
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 24 November 2005 - 07:31 AM

[!--quoteo(post=321161:date=Nov 22 2005, 08:44 PM:name=WhyWindows)--][div class=\'quotetop\']QUOTE(WhyWindows @ Nov 22 2005, 08:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You could try a more extreme option - restart the entire server itself?
But you won't be able to do that if more than one site is being hosted on the pc - if its a dedicated server, it shouldn't be a problem, just use:

shutdown -r -f -t 00

This will make the pc restart immediately, forcing all services to stop.
[/quote]

I found something called PsService, this tool can stop, start and restart a service, plus it works through PHP...
I just sends an exec command and my problem is solved...

Thanks guys..

//Ishan Jain




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users