Can a single Apache server handle both Tomcat and PHP?

后端 未结 4 796
滥情空心
滥情空心 2021-02-04 15:26

I have a requirement as to have a single server with both a Java application and a PHP application, running on the same Apache. Is this possible?

This question may be ve

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 15:45

    Yes you can do that. Essentially you have to run the Apache (+ PHP) server on one port and the Tomcat server on a different port.

    • You can expose the 2nd port to the outside world, and have your URLs use either port 80 for Apache / PHP or (say) 8080 for the Java server. This simple, but you may find that upstream firewalls prevent a remote web browser from connecting to any port other than 80.

    • You can configure your Apache server as a reverse proxy for the Java server. So for instance, the Apache server might recognize that http://site.com/javaapp/foo.html is for the Java server, and relay requests for that URL to http://localhost:8080/javaapp/foo.html.

    There is a whole chapter of the Apache documentation about configuring forward and reverse proxies using mod_proxy.

提交回复
热议问题