ishan Posted November 16, 2005 Share Posted November 16, 2005 I am wondring if there is any possiblety to restart apache service with only php from a remote host... //Ishan Jain Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/ Share on other sites More sharing options...
neylitalo Posted November 16, 2005 Share Posted November 16, 2005 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 Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9677 Share on other sites More sharing options...
ishan Posted November 21, 2005 Author Share Posted November 21, 2005 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. Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9757 Share on other sites More sharing options...
lilcam Posted November 21, 2005 Share Posted November 21, 2005 [!--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" Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9760 Share on other sites More sharing options...
ishan Posted November 22, 2005 Author Share Posted November 22, 2005 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9775 Share on other sites More sharing options...
haydndup Posted November 22, 2005 Share Posted November 22, 2005 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 Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9777 Share on other sites More sharing options...
ishan Posted November 22, 2005 Author Share Posted November 22, 2005 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9778 Share on other sites More sharing options...
haydndup Posted November 22, 2005 Share Posted November 22, 2005 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9781 Share on other sites More sharing options...
ishan Posted November 24, 2005 Author Share Posted November 24, 2005 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/2871-restart-apcahe/#findComment-9837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.