I'm building an application for a company and I also have to handle the deployment. The application is a java restful API which I usually deploy on a tomcat. The front end for the application in written in PHP (not by me) and will be installed on the same machine. The back end must be reachable both from the front-end and from the web.
What is the best approach, considering that this is a production environment?
Also are there downsides on having both the back-end and front-end on the same machine?
If your back-end uses the Servlet API, you require a servlet server and Tomcat is a common choice. Even if Tomcat provides CGIServlet, I believe nobody uses it on production servers to run PHP scripts. So you need at least two servers.
I would extend it to three servers and run:
localhost
),PHP-FPM
. It does not have to proxy Tomcat, since everything is on the same machine.