1

I want to run my php code in Tomcat9, but Tomcat has no support for php. I tried following this guide but it didn't work https://stackoverflow.com/questions/779246/run-a-php-app-using-tomcat

Is there any other way that can help me to run PHP in Apache Tomcat?

James Westgate
  • 11,306
  • 8
  • 61
  • 68
Jayzz
  • 117
  • 1
  • 9
  • tomcat is for java, not for PHP or python or c or anything else. I really don't understand why you want to do that. – svgta Sep 01 '22 at 07:25
  • @svgta I have a webgis project running on Tomcat and connect to PostgreSQL via GeoServer, but now I want to connect directly to PostgreSQL, I wrote php code to do it so now I hope to be able to run that PHP code in tomcat. – Jayzz Sep 01 '22 at 07:33
  • That post is 13 years old - it was a bad idea back then and it's worse now. You cannot realistically run PHP in Tomcat. One thing you can look at is using something like Apache HTTPD to act as a PHP server and as a proxy server to Tomcat. – stdunbar Sep 01 '22 at 14:02
  • Why do you want to run php in tomcat instead of Apache? By any chance are you confusing Apache Tomcat with Apache webserver? – Usman Mutawakil Sep 03 '22 at 06:07
  • @Usman Mutawakil looks like I was really confused, I'm using apache tomcat9. So is there any way to do that? Thanks you. – Jayzz Sep 04 '22 at 14:22
  • @Jayzz Why are you using Apache Tomcat and not Apache Webserver for PHP? – Usman Mutawakil Sep 04 '22 at 23:13
  • @Usman Mutawakil as I said in the previous comment, I have a webgis with javascript code running on Apache Tomcat so I am forced to insert my php code there – Jayzz Sep 05 '22 at 01:08
  • I see. You might want to add that into your description. I think thats why someone voted to close it....Is it a lot of PHP code? It might be easier to just write a war file in java and deploy that into the same container. Is your goal only to communicate with the Postgress database? If so why not run your php code in a separate server and use the same database credentials? – Usman Mutawakil Sep 05 '22 at 16:36

1 Answers1

2

You can use quercus (https://www.caucho.com/resin-3.1/doc/quercus.xtp) , get it at https://drive.google.com/file/d/1dCvrrTHepkpqf0PmO-fbFlfKp-cY2663/view

See step-by-step guide at https://www.youtube.com/watch?v=seQHzVwUdYo

Vy Do
  • 46,709
  • 59
  • 215
  • 313