Showing posts with label quercus. Show all posts
Showing posts with label quercus. Show all posts

Saturday, July 3, 2010

Using PHP with Red5

The default installation of Red5 doesn't include support for PHP. And since Red5 is ran by Tomcat, this means we need Tomcat to handle PHP.

I found a tutorial that requires you to recompile Tomcat with PHP-handling. Tedious task for a simple need of enabling PHP. Good thing, there's Quercus -- a 100% Java implementation of PHP 5. This means that it can be used with Tomcat.

What I did was, download Quercus 4.0.3 binary, then extracted file to a temporary location.

Now move the following files from the Quercus' temporary location,
  • /WEB-INF/lib/inject-16.jar
  • /WEB-INF/lib/javamail-141.jar
  • /WEB-INF/lib/resin.jar

to your Red5 installation's /webapps/root/WEB-INF/lib/{here}. Create the /lib directory on Red5's /root/WEB-INF if needed.

Now, here's the part where you need to be cautious.

From Red5's /webapps/root/WEB-INF/ location, then open web.xml.

Add the following before the </web-app> tag.
<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>

<welcome-file-list>
  <welcome-file>index.php</welcome-file>
</welcome-file-list>



Now, try creating a helloworld.php to test Quercus.

Make sure to restart your Red5.