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-name>Quercus Servlet</servlet-name>

  <servlet-name>Quercus Servlet</servlet-name>


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

Make sure to restart your Red5.


Anonymous said...

I do your instructions but this doesn't work

David said...

I can confirm that this works. Perhaps would make things clearer by saying to put the HelloWorld.php into your Red5\webapps\root directory and to test it by running http:\\ipaddress:port\HelloWorld.php where ipaddress is the ip address to access your Red5 and port signifies what http port you have configured in

Anonymous said...

Unfortuntely, AMFPHP is not working this way. There is a known bug:

Ajayi Oluwaseun Emmanuel said...

worked like magic, I just moved the 3 jars to my red5/lib directory, copied your code and pasted it in my current application's web.xml file restarted red5 and ran my php code from and it worked like magic. You are a saviour.

st@uros said...

Perfect worked for me too using Red5 RC1!! Thanks a lot!

st@uros said...
This comment has been removed by the author.
toto said...

Please, how to develop later with red 5 using php ??

I need an example of the example file, or the test file I mean,

Thank you so much !!

creek23 said...

hi toto,

Red5 is technically built for use of Adobe Flash -- you code via ActionScript.

The need for PHP comes for other non-Red5 related server-calls from ActionScript, like say, AMFPHP.


Lorenzo said...

You made my day!

Lorenzo said...

You made my day!