如何在 Ubuntu 上并行运行 Apache Tomcat 和 Apache2?

发布于 2024-10-31 13:50:18 字数 313 浏览 1 评论 0原文

我遇到了问题。我同时进行 pHp 开发和 JSF 开发。但我遇到了问题。你看,不久前我安装了 Apache2,以便我可以做 pHp。但一个月后我不得不安装 Apache Tomcat。这时候问题就出现了。我遵循了 tomcat.apache.org 站点上针对 Ubuntu 的所有说明。它没有安装。而127.0.0.1始终指向Apache2的页面。我尝试了 127.0.0.1:8080 但没有返回任何内容。

所以我在这里问你,当我想使用 Tomcat 时,是否可以关闭 Apache2?并在我需要的时候重新打开它?

I have run into a problem. I do both pHp development and JSF development. But i ran into a problem. You see, a while ago I installed Apache2 so that I could do pHp. But then a month later I had to install Apache Tomcat. That's when the problem arose. I followed all the instruction give on the tomcat.apache.org site for Ubuntu. It did not install. And 127.0.0.1 always pointed to Apache2's page. I tried 127.0.0.1:8080 but that did not return anything.

So I am here to ask you if there is anyway I can turn off Apache2 when i want to work with Tomcat? And turn it back on whenever I want?

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

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

发布评论

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

评论(1

瘫痪情歌 2024-11-07 13:50:18

如果您希望两台服务器在同一主机上可用,则应将它们配置为侦听不同的端口。

现在,如果您已配置 Apache要侦听 80 并让 Tomcat 侦听端口 8080,您应该能够通过 http://localhost:80 访问它们(或者只是 http://localhost)和 http://localhost:8080 分别。

您应该确保两台服务器实际上也已启动。 netstat -npl | netstat -npl | netstat -npl | netstat -npl | netstat -npl grep :8080 和 netstat -npl | grep :80 应该可以帮助您确定哪些进程绑定到这两个端口。如果端口已绑定,但不说 javaapache2,则说明有其他进程正在侦听这些端口,这将阻止尝试绑定的服务器从启动到该端口。

对于 Apache2,您还可以运行 service apache2 status 来查看状态。


但是,如果您想运行绑定到同一端口(也许是 80)的两台服务器,那么正如您似乎已经猜到的那样,您将不得不停止另一个。

  • 要停止 Apache2,请执行命令 service apache2 stop
  • 停止 Tomcat 取决于您启动它的方式。您可以简单地运行 ${CATALINA_HOME}/bin 中的 shutdown.sh 脚本,即 Tomcat 安装文件夹中的 bin 目录。

注意

您[可能]需要以 root 身份执行命令,因此需要添加前缀 sudo

The two servers should be configured to listen on different ports if you want them both available on the same host.

Now, if you've configured Apache to listen on 80 and Tomcat to listen on port 8080, you should be able to access them at http://localhost:80 (or just http://localhost) and http://localhost:8080 respectively.

You should ensure both the servers are actually up as well. netstat -npl | grep :8080 and netstat -npl | grep :80 should help you identify what processes are bound to these two ports. If the ports are bound but don't say java or apache2, you've got some other process listening on these ports and that's going to stop the server that tries to bind to that port from starting up.

For Apache2, you could also run service apache2 status to see what the status is.


If however, you want to run both servers bound to the same port( perhaps 80) then as you seem to have guessed, you'll have to stop the other.

  • To stop Apache2, execute the command service apache2 stop
  • Stopping Tomcat depends on how you started it. You might simply run the shutdown.sh script in ${CATALINA_HOME}/bin i.e. the bin directory in your Tomcat installation folder.

Note

You will [probably] need to execute the commands as root so you'll need to prefix sudo.

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