如何在 Ubuntu 上并行运行 Apache Tomcat 和 Apache2? [英] How to run Apache Tomcat and Apache2 on Ubuntu Parallel to each other?

查看:39
本文介绍了如何在 Ubuntu 上并行运行 Apache Tomcat 和 Apache2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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?

推荐答案

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

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

现在,如果您已将 Apache 配置为侦听 80 端口并将 Tomcat 配置为侦听端口 8080,则您应该可以通过 访问它们http://localhost:80(或只是 http://localhost)和 http://localhost:8080 分别.

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.

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

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.

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

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

但是,如果您想运行绑定到同一端口(可能是 80)的两台服务器,那么正如您似乎已经猜到的那样,您必须停止另一个.

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.

  • 要停止Apache2,执行命令service apache2 stop
  • 停止 Tomcat 取决于您如何启动它.您可以简单地运行 ${CATALINA_HOME}/bin 中的 shutdown.sh 脚本,即 Tomcat 安装文件夹中的 bin 目录.
  • 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.

注意

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

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

这篇关于如何在 Ubuntu 上并行运行 Apache Tomcat 和 Apache2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆