views:

92

answers:

2

Hello all i need to find away to stop/terminate apache web server that is running on my local pc when i close the site that is running in my local pc (for example http://localhost:8080) or when i close the browser that display/load the localhost site that the local apache web server is running . what is the preferred way ?

+1  A: 

I don't think this can be done. There's no connection between a browser and the web server after the site's elements have been downloaded, so there's no way for the web server to know whether some browser is still displaying the page. In my opinion what you want to do just can't be done.

Thorsten Dittmar
im sure there is somekind of trick or work around for this but the question is what
No - I'm quite sure there's not.
Thorsten Dittmar
A: 

there's javascript "onbeforeunload" ... you could have a cgi script running as root terminate apache when the "onbeforeunload" triggers it via ajax.

but that's only really doable if you're the only one visiting that page - otherwise anyones closed window would be the end of apache.

lixlpixel
Will OnBeforeUnload be called when he closes the window? It won't work reliably when I disable JavaScript in my browser and visit his site...
Thorsten Dittmar