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 ap开发者_运维技巧ache web server is running . what is the preferred way ?
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.
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.
精彩评论