Installing and Configuring Red5 Media Server on CentOS 7
Red5 is a Java-based open-source media server that powers Flash-based multi-user applications. It enables live audio and video streaming, shared remote objects for multiplayer gaming, client stream recording (in FLV or AVC+AAC formats), real-time data sync, and more.
This guide walks you through the complete setup process of deploying a Red5 Media Server on a CentOS 7 system.
System Requirements
- A user account with
sudo
privileges. - A CentOS 7 x64 server, with at least 1 GB of available RAM.
Step 1: Update Your CentOS Server
Before installing any new software, it’s crucial to update the server to the latest available packages. Run the following commands to clean the cache and perform a full system update:
yum clean all
yum -y update
Step 2: Install Java
Red5 requires Java to run. Follow these steps to download and set up the Java SE Development Kit 8 from Oracle’s official source:
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz"
tar xzf jdk-8u161-linux-x64.tar.gz
Configure Java using the alternatives
system:
alternatives --install /usr/bin/java java /opt/jdk1.8.0_161/bin/java 2
alternatives --config java
Now define paths for javac
and jar
commands using the same method:
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_161/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_161/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_161/bin/jar
alternatives --set javac /opt/jdk1.8.0_161/bin/javac
Set Environment Variables
Define the global environment variable for JAVA_HOME
as shown:
export JAVA_HOME=/opt/jdk1.8.0_161
Set JRE_HOME and Update the System PATH
To ensure the Java Runtime Environment is correctly referenced, define the JRE_HOME
environment variable as follows:
export JRE_HOME=/opt/jdk1.8.0_161/jre
Next, append the JDK and JRE binaries to your system’s PATH
variable:
export PATH=$PATH:/opt/jdk1.8.0_161/bin:/opt/jdk1.8.0_161/jre/bin
Step 3: Install the Red5 Media Server
Download the latest stable release of Red5 from the official GitHub repository:
cd ~
wget https://github.com/Red5/red5-server/releases/download/v1.0.9-RELEASE/red5-server-1.0.9-RELEASE.tar.gz
Extract the downloaded archive:
tar xvzf red5-server-1.0.9-RELEASE.tar.gz
Rename the extracted directory to red5
and move into it:
mv red5-server red5
cd red5
Start Red5 in the background using the command below:
sh red5.sh &
Once running, you can access the Red5 welcome page by navigating to your server’s IP address on port :5080
using a web browser.
Step 4: Enable Red5 to Start on Boot
If you’d like Red5 to launch automatically when the server boots, begin by creating a new init script:
sudo nano /etc/init.d/red5
Step 5: Add the Red5 Init Script
Insert the following content into the newly created /etc/init.d/red5
file. This script will control how the Red5 server starts, stops, and restarts:
#!/bin/sh
### BEGIN INIT INFO
# Provides: red5
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Red5 server
### END INIT INFO
start() {
cd /opt/red5 && nohup ./red5.sh > /dev/null 2>&1 &
echo 'Service started' >&2
}
stop() {
cd /opt/red5 && ./red5-shutdown.sh > /dev/null 2>&1 &
echo 'Service stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
After adding the script, press Ctrl + O to save and Ctrl + X to exit the editor.
Step 6: Make the Script Executable
Set the correct permissions so the script can be executed:
sudo chmod ugo+x /etc/init.d/red5
Step 7: Enable Red5 to Start on Boot
Install the sysv-rc-conf
utility, which manages startup services:
sudo apt-get install sysv-rc-conf
Then activate Red5’s automatic startup:
sudo sysv-rc-conf red5 on
Step 8: Manage Red5 Using Service Commands
Now, you can easily control the Red5 server using standard service commands:
sudo service red5 start
sudo service red5 stop
sudo service red5 restart
Final Step: Complete the Red5 Setup in Your Browser
To finish setting up Red5, open a web browser and go to:
http://[your-ip-address]:5080
Replace [your-ip-address]
with the actual public IP address of your VPS. To access demo applications, navigate to:
http://[your-ip-address]:5080/installer/
Your Red5 media server is now fully installed and ready for use.
Conclusion
Setting up a Red5 Media Server on CentOS 7 involves several key steps—ranging from installing Java, configuring environment variables, and setting up the server itself, to enabling automatic startup via an init script. With everything in place, you can now leverage Red5’s powerful media capabilities for live streaming, real-time data sharing, or testing its demo applications.
This setup provides a robust foundation for building interactive multimedia applications, all hosted on your own server environment. Be sure to explore Red5’s additional features and configurations as your project evolves.