Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing apache with php 1

Status
Not open for further replies.

overyde

Programmer
May 27, 2003
226
ZA
Hi,
How do I close apache and mysql from php?
Would I need to use a dll as it will be running on windows machine? The environment is apache 2.0, mysql 5.x, and php 5.
Thanx

Reality is built on a foundation of dreams.
 
are you asking how to shut down the webserver via PHP?

This sounds like a dangerous question to answer... but it's a shell issue. Basically you need to figure out whatever the commandline is to stop the service (since you're talking windows) and then run it via shell_exec() or one of the similar functions. Usually the command line is something akin to NET STOP APACHE2


But be warned, this is best used for CLI PHP, I'm not really sure how the script would respond to having Apache shutdown if it was also in charge of running it.
 
Hi Skiflyer...
To put your mind at ease...I'm not looking to shutdown a public web server but rather a portable web server running from a usb flash drive. I got it to start now not sure how to get it to stop when the user wants to quit.
Thx
;)

Reality is built on a foundation of dreams.
 
heh, my mind was already at ease after I looked at your member profile... hope it works out for you.
 
hmmm...
To try figure out the command has been the tough one. You see apache is run as a console (being portable one does not want to run it as a service) and the major issue is that when the user escapes/quits from the app I need the console window to either be hidden or closed. Can't seem to get it right!

Reality is built on a foundation of dreams.
 
oh and btw, I'm curious, and would gladly like to help, but I'm mostly guessing and poking around helping you find the right apache command line, so you might be better off in the apache forum at this point
 
from a php script:
Code:
echo "starting apache....\n";
flush();
pclose(popen('start pdrive\\apache2\\bin\\apache.exe','r'));

Reality is built on a foundation of dreams.
 
cool...
If I get it to work I'll forward it on to you if you're interested.

Reality is built on a foundation of dreams.
 
Ok...
Making progress...
managed to hide the apche console by making it a service that installs by itself and give it another name...

Now to stop it! Is this the correct syntax:
Code:
shell_exec("pdrive\\apache2\\bin\\apache.exe -n portapach -k stop");


Reality is built on a foundation of dreams.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top