Tomcat Quercus Php doesn't work properly

530 Views Asked by At

I'm trying to run a little piece of Php code in my Tomcat 8.0.36. I have seen I need Quercus in order to do that.

I have uncompressed the Quercus.war in my tomcat/webapps and renamed it to php (tomcat/webapps/php) and I have created a file (called info.php) with this code:

<?php
phpinfo();
?>

When I start the server, if I go to

localhost:8080/php/info.php

I get the result I want to, but if I do the same in

localhost:8080/myApp/info.php

the browser just show me the php code as plain text.

How can I fix this?

Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

I have found the solution: Just need to use servlet.

Put in the web.xml :

<servlet>
       <servlet-name>Quercus Servlet</servlet-name>
       <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
</servlet>
<servlet-mapping>
       <servlet-name>Quercus Servlet</servlet-name>
       <url-pattern>*.php</url-pattern>
</servlet-mapping>

And add to pom.xml this:

<dependency>
        <groupId>com.caucho</groupId>
        <artifactId>quercus</artifactId>
        <version>4.0.45</version>
</dependency>