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
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.