Jump to content

Archived

This topic is now archived and is closed to further replies.

ishan

Restart Apcahe

Recommended Posts

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

 

//Ishan Jain

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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) 319097[/snapback][/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.

 

Share this post


Link to post
Share on other sites

[!--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) 320634[/snapback][/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...

 

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

Share this post


Link to post
Share on other sites

[!--quoteo(post=320721:date=Nov 21 2005, 05:01 PM:name=lilcam)--][div class=\'quotetop\']QUOTE(lilcam @ Nov 21 2005, 05:01 PM) 320721[/snapback][/div][div class=\'quotemain\'][!--quotec--]

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

 

Once server is down it will not execute php any futher....

and with "net stop Apache2" it is gone and script is gone.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

[!--quoteo(post=321069:date=Nov 22 2005, 02:08 PM:name=WhyWindows)--][div class=\'quotetop\']QUOTE(WhyWindows @ Nov 22 2005, 02:08 PM) 321069[/snapback][/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

It should but my server just ignores all the executable files and commands exept the basc ones in the Command Promopt

Share this post


Link to post
Share on other sites

[!--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) 321071[/snapback][/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

 

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.

Share this post


Link to post
Share on other sites

[!--quoteo(post=321161:date=Nov 22 2005, 08:44 PM:name=WhyWindows)--][div class=\'quotetop\']QUOTE(WhyWindows @ Nov 22 2005, 08:44 PM) 321161[/snapback][/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.

 

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.