如何检测本地主机网站已关闭,然后喊 apache web 服务器

发布于 2024-08-09 18:41:35 字数 203 浏览 5 评论 0原文

当我关闭本地电脑上运行的网站时,我需要找到停止/终止本地电脑上运行的 apache Web 服务器的方法(例如 http://localhost:8080) 或当我关闭显示/加载本地 apache Web 服务器正在运行的本地主机站点的浏览器时。 首选方式是什么?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筑梦 2024-08-16 18:41:35

我认为这是不可能的。下载网站元素后,浏览器和 Web 服务器之间没有任何连接,因此 Web 服务器无法知道某些浏览器是否仍在显示该页面。在我看来,你想做的事是做不到的。

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.

指尖上得阳光 2024-08-16 18:41:35

有 javascript“onbeforeunload”...
当“onbeforeunload”通过ajax触发它时,您可以有一个以root身份运行的cgi脚本来终止apache。

但只有当你是唯一访问该页面的人时,这才是真正可行的 - 否则任何人关闭的窗口都将是 apache 的终结。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文