如何在 Ubuntu 上并行运行 Apache Tomcat 和 Apache2?
我遇到了问题。我同时进行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望两台服务器在同一主机上可用,则应将它们配置为侦听不同的端口。
现在,如果您已配置 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 应该可以帮助您确定哪些进程绑定到这两个端口。如果端口已绑定,但不说
java
或apache2
,则说明有其他进程正在侦听这些端口,这将阻止尝试绑定的服务器从启动到该端口。对于 Apache2,您还可以运行
service apache2 status
来查看状态。但是,如果您想运行绑定到同一端口(也许是 80)的两台服务器,那么正如您似乎已经猜到的那样,您将不得不停止另一个。
service apache2 stop
${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
andnetstat -npl | grep :80
should help you identify what processes are bound to these two ports. If the ports are bound but don't sayjava
orapache2
, 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.
service apache2 stop
shutdown.sh
script in${CATALINA_HOME}/bin
i.e. thebin
directory in your Tomcat installation folder.Note
You will [probably] need to execute the commands as root so you'll need to prefix
sudo
.