title: JavaBridge - Probably php was not installed as "/usr/bin/php-cgi" or "c:/php/php-cgi.exe"
body: <p>I am trying to setup a JavaBridge between my Java-application and Apache/PHP application. First I tried through CLI => </p>
  
  <pre><code>MacBook-Pro:php-java-bridge_5-2 username$ java -classpath JavaBridge.war TestInstallation
  Starting a simple servlet engine: [/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/bin/java, -jar, /Users/username/Downloads/php-java-bridge_5-2/ext/JavaBridge.jar, SERVLET_LOCAL:8081]
  Sep 03 12:32:34 VMBridge INFO : VM                  : 1.8.0_92@http://java.oracle.com/
  Sep 03 12:32:34 VMBridge INFO : VMBridge version             : 5.2.2    
  Sep 03 12:32:34 VMBridge INFO : logFile             : 
  Sep 03 12:32:34 VMBridge INFO : default logLevel    : 3
  Sep 03 12:32:34 VMBridge INFO : socket              : SERVLET_LOCAL:8081
  Sep 03 12:32:34 VMBridge INFO : java.ext.dirs       : /Users/username/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
  Sep 03 12:32:34 VMBridge INFO : php.java.bridge.base: /Users/username
  Sep 03 12:32:34 VMBridge INFO : thread pool size    : 20
  Sep 03 12:32:34 VMBridge INFO : JavaBridgeRunner started on port INET_LOCAL:8081
  Invoking php: [php-cgi, -n, -d, allow_url_include=On, /Users/username/Downloads/php-java-bridge_5-2/test.php]
  java.lang.RuntimeException: Could not run PHP ([php-cgi, -n, -d, allow_url_include=On, /Users/username/Downloads/php-java-bridge_5-2/test.php]), please check if php-cgi is in the path.
  </code></pre>
  
  <p>This seemed without success so I tried another option; I installed TomCat with Apache Mamp. The installation went well and I deployed the JavaBridge. </p>
  
  <p>Unfortunately when trying to accessing it, I receive a similar error as when I was trying to run it throughout the CLI. </p>
  
  <pre><code>HTTP Status 500 - An IO exception occured. Probably php was not installed as "/usr/bin/php-cgi" or "c:/php/php-cgi.exe"
  
  type Exception report
  
  message An IO exception occured. Probably php was not installed as "/usr/bin/php-cgi" or "c:/php/php-cgi.exe"
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: An IO exception occured. Probably php was not installed as "/usr/bin/php-cgi" or "c:/php/php-cgi.exe"
   or "/Applications/MAMP/tomcat/webapps/JavaBridge/WEB-INF/cgi/php-cgi-x86_64-mac[.sh]|[.exe]".
  Please see "php_exec" in your WEB-INF/web.xml and WEB-INF/cgi/README for details.
      php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:366)
      php.java.servlet.CGIServlet.doGet(CGIServlet.java:469)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  root cause
  
  java.io.IOException: Cannot run program "php-cgi" (in directory "/Users/user"): error=2, No such file or directory
      java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
      java.lang.Runtime.exec(Runtime.java:620)
      php.java.bridge.Util$Process.start(Util.java:839)
      php.java.bridge.Util$ProcessWithErrorHandler.start(Util.java:937)
      php.java.bridge.Util$ProcessWithErrorHandler.start(Util.java:991)
      php.java.servlet.PhpCGIServlet$CGIRunner.execute(PhpCGIServlet.java:271)
      php.java.servlet.CGIServlet.handle(CGIServlet.java:400)
      php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:355)
      php.java.servlet.CGIServlet.doGet(CGIServlet.java:469)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>At the moment I am out of inspiration of solving this problem, any advice?</p>