Enabling PHP with Red5 open source Flash media server

Recently I was installing a Red5 media server. And to my surprise came across, that by default red5 installation doesn’t support PHP.
And as it is ran by tomcat, so we need to make tomcat to handle PHP.
There is a tutorial available guiding you to recompile Tomcat with PHP-handling. A little Complex  thing to go with just to enable PHP.
Well there’s a rescuer  — Quercus  a 100% Java implementation of PHP5.
So it can be used with tomcat. Recently tried it for myself and it worked for me.
Below are the steps to enable php in red5 itself.
  1. Firstly  download Quercus 4.0.3 binary, and extract it some location.(as for /home/quercus)
  2. Move this files from Quercus extracted location.
  • /WEB-INF/lib/inject-16.jar
  • /WEB-INF/lib/javamail-141.jar
  • /WEB-INF/lib/resin.jar

to the Red5 installation’s /webapps/root/WEB-INF/lib/.

3. Create  /lib directory on Red5’s /root/WEB-INF if not already there.

4. This part involves editing the configuration .xml file.
Go to Red5’s /webapps/root/WEB-INF/ location.
Edit web.xml.
Add this below tags  before the closing end </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>

 
5. Thats it we have enabled php for red5 using quercus.
Now lets test it.
Create a test.php file inside your /var/lib/red5/webapps/root/
Add lines as <?php phpinfo(); ?> in test.php file

6. Now open a link to your server http://127.0.0.1:5080/test.php
You will see the quercus info and PHP variables.
Restart the red5 media server if things don’t work out for you.

This entry was posted in Linux, Tech Guides and tagged . Bookmark the permalink.