# Installing Red5 1.0 RC2 on Ubuntu 10.04

📅

This weekend I decided to sit down and install Red5 Media Server on my Ubuntu box in preparation for an upcoming project. I chose Red5 because it's the only free and open source software I could find that correctly implements Flash media streaming and will work on Linux.

I couldn't find a lot of good documentation in one place on how to install this software on my particular setup, so I thought I'd document my process here. First, obviously, you have to download the code from Red5. This is not as simple as it sounds. I tried the tarballs on Red5's site, but they wouldn't compile on my machine. I ended up getting the source from their subversion repo and it compiled fine. To do this, you'll first need to install a few things on your Ubuntu box. I installed Java, Ant, Ivy, and subversion to get everything to work.

Here's what you need to do that:
 sudo apt-get update sudo apt-get install java-package openjdk-6-jdk ant ivy subversion 

Then you need to check the code out of their SVN repo:
 svn export http://red5.googlecode.com/svn/java/server/tags/1_0rc2/ 

Now you just need to build it with ant:
 cd 1_0rc2 make sudo make install 

This will set up all of the libraries and such that you need to use Red5 and will create a directory called "dist" that contains the binaries that make up the Red5 server. Move this somewhere on your machine, I put mine in /usr/share/red5.

After doing this, you'll need to edit the startup script OR change some environment variables to get the server to start. I did a little of both; I edited the script to indicate where the server is installed, but I already had $JAVA_HOME set, so I left that one alone. The script you need to modify is called red5.sh. Just add a line at the beginning like this:  export RED5_HOME=/usr/share/red5;  Obviously, you should change /usr/share/red5 to the location where you installed Red5. Red5 is smart enough to detect Java, but if you have muliple versions installed, you may need to point it at the right version by setting your$JAVA_HOME accordingly. For me, it looks like this:
 export JAVA_HOME=/usr/lib/jvm/java-1.5.0-gcj-4.4  Yours will be different depending on what versions of java you have installed, but you do not need to do this if you only have one version of Java installed.

Now, you should be able to start Red5 by running
/usr/share/red5/red5.sh
Once it's started, you should be able to see the success page at localhost:5080. It looks like this:

Hooray. Now I want (and I imagine you do too) an init script so the daemon starts up when the server boots. Fortunately, there are already instructions for how do to this on the Red5 Wiki. I'll reproduce the relevant bits from the Debian/Ubuntu section here. Create /etc/init.d/red5 in your favorite editor:
sudo -e /etc/init.d/red5
Then just paste the code from their wiki into this file, changing the variables to reflect your installation:
 #! /bin/sh # init script for Red5 # /etc/init.d/red5 RED5_USER=root RED5_HOME=/usr/share/red5 RED5_PROG=red5 test -x $RED5_HOME/$RED5_PROG.sh || exit 5 case "$1" in start) echo -n "Starting Red5" echo -n " " cd$RED5_HOME su -s /bin/bash -c "$RED5_HOME/$RED5_PROG.sh &" $RED5_USER ## su -s /bin/bash -c "$RED5_HOME/$RED5_PROG.sh > start.log &"$RED5_USER sleep 2 ;; stop) echo -n "Shutting down Red5" echo -n " " su -s /bin/bash -c "killall -q -u $RED5_USER java"$RED5_USER sleep 2 ;; restart) $0 stop$0 start ;; esac  Don't forget to make root the owner and to make it executable:
 sudo chown root /etc/init.d/red5 sudo chmod 755 /etc/init.d/red5 

This code in its current state dumps rather a lot of text into your terminal when you start it, and I don't like this. To prevent it, just uncomment this line:
## su -s /bin/bash -c "$RED5_HOME/$RED5_PROG.sh > start.log &" \$RED5_USER Then comment out the line before it and now you can just start Red5 as you would any other service, i.e.
sudo /etc/init.d/red5 start My server boots to runlevel 3, so I also added a link to this in /etc/rc3.d:
sudo update-rc.d red5 80 3 If you have a more standard installation, you could also just do this to create links for all runlevels:
sudo update-rc.d red5 defaults

That's it. Now you should have a working Red5 installation on your Ubuntu 10.04 box. A brief note about the OFLA Demo (the first one I tried). In version 1.0 RC 2, the page points to localhost:5080 as the server that holds the media we want to stream. This is all well and good if you're using the server to access the demos, but if you want to try it from another computer (and why wouldnt' you), you have to modify index.html to point to your server's actual IP. I just used its LAN IP since I'm only going to be testing it from my LAN. Anyway, I hope this helps someone because I had quite a time finding all of this information.