Jump to content


Photo

restarting apache via php


  • Please log in to reply
6 replies to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 11 July 2006 - 02:34 PM

I am wondering what is the best way to restart or stop and start Apache via php. Would exec() be the best way to achieve this? Any suggestions would be great.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:52 PM

exec and the other functions that allows you to send commands to the server would be just fine.

#3 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 12 July 2006 - 12:35 AM

Although maybe they are mutually exclusive since the PHP script is running under Apache, hmm..

Anyway, you could do this:
$result = shell_exec('C:\path\to\apache.exe -k restart');

May do the trick.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 12 July 2006 - 06:46 AM

I have tried what you suggested and nothing happened.

I also tried this
<?php
$result = popen( 'C:\Program Files\apache\bin\apache.exe -k restart', 'r');
echo fread( $result, 4096 );
pclose($result);
?>

This works fine for reloading Bind but not for Apache. Any suggestions?

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 12 July 2006 - 07:04 AM

[code]When I try it this way 

[code=php:0]<?php
$result = popen( 'C:\Program Files\apache\bin\apache.exe restart', '-k');
echo fread( $result, 4096 );
pclose($result);
?>[/code]

I get the following error 
[/code]
Faulting application Apache.exe, version 2.0.55.0, faulting module ntdll.dll, version 5.1.2600.2180, fault address 0x000010f3.

This is in the windows event viewer.

Any suggestions on a better way to do this

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 12 July 2006 - 07:28 AM

When I used Windows I once had something called Apache2Triad installed. From it's control center I could restart Apache. You might wan't to check the source of that out.

#7 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 12 July 2006 - 08:32 AM

I think that I am going to try writing a batch file. Thanks for the suggestions

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users