![]() |
|
Guide How to Install an NGINX-Based Media Streaming Server - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: aaPanel (https://adminsforum.com/Forum-aapanel) +---- Forum: aaPanel Guides & Tutorials (https://adminsforum.com/Forum-aapanel-guides-tutorials) +----- Forum: aaPanel Websites & Web Servers Guides (https://adminsforum.com/Forum-aapanel-websites-web-servers-guides) +----- Thread: Guide How to Install an NGINX-Based Media Streaming Server (/Thread-guide-how-to-install-an-nginx-based-media-streaming-server) |
How to Install an NGINX-Based Media Streaming Server - ALEX - 10-19-2026 You can run an NGINX-based RTMP/HLS media server on an aaPanel VPS without replacing the Nginx binary that serves your websites. This guide builds a separate streaming process, publishes a generated test video and verifies the HLS output. It is a localhost lab installation, not an Internet-facing streaming service. What you will build FFmpeg sends H.264 video and AAC audio to an RTMP application called live. The module creates a changing .m3u8 playlist and .ts video segments. An HTTP listener serves those files to an HLS-capable player. RTMP is the ingest connection; HLS is the playback format. An ordinary browser does not play an rtmp:// URL as an HTML video. Tested environment Ubuntu 22.04, aaPanel server, Nginx 1.30.6 compiled separately, nginx-rtmp-module commit 6c7719d0ba32e00b563ec70bd43dad11960fa9c4 and FFmpeg 4.4.2. The existing aaPanel Nginx was 1.30.5. We also checked module compilation against 1.30.5. No aaPanel Nginx binary was overwritten. 1. Check prerequisites and ports Use a disposable Linux lab with SSH/root access, a backup, free disk space and a compiler. A domain is not needed for this localhost test. Commands below assume a root shell; do not paste a root prompt as part of the command. Code: id
cat /etc/os-release
df -h /
/www/server/nginx/sbin/nginx -V 2>&1
ss -lntH '( sport = :11935 or sport = :18085 )'
getent passwd wwwInstall build dependencies from Ubuntu's repositories if missing: Code: apt-get update
apt-get install --no-install-recommends build-essential libpcre3-dev libssl-dev zlib1g-dev git curl ffmpeg2. Download and pin the source Keep these variables in the same SSH shell. The dated names identify this example's isolated directories; use fresh empty directories for your own lab. Code: RTMP_WORK=/root/adminsforum-rtmp-review-20261019
RTMP_PREFIX=/opt/adminsforum-rtmp-lab-20261019
mkdir -p "$RTMP_WORK"
cd "$RTMP_WORK"
git clone https://github.com/arut/nginx-rtmp-module.git
git -C nginx-rtmp-module checkout --detach 6c7719d0ba32e00b563ec70bd43dad11960fa9c4
curl -fL https://nginx.org/download/nginx-1.30.6.tar.gz -o nginx-1.30.6.tar.gz
sha256sum nginx-1.30.6.tar.gz
tar -xzf nginx-1.30.6.tar.gz3. Fix the configure-directory mistake and build The older aaPanel forum recipe ends its prefix script with ./configure after changing only to /www/server/nginx/src. That is not a complete Nginx build workflow. The RTMP repository supplies a config file, not its own configure executable. Run Nginx's configure from the extracted Nginx source directory and pass the module's absolute path: Code: cd "$RTMP_WORK/nginx-1.30.6"
./configure --prefix="$RTMP_PREFIX" --with-http_ssl_module --add-module="$RTMP_WORK/nginx-rtmp-module"
make -j2
./objs/nginx -V 2>&1Do not run make install against /www/server/nginx. Copy only the newly built binary into the separate prefix: Code: install -d -m 0755 "$RTMP_PREFIX/sbin" "$RTMP_PREFIX/conf"
install -m 0755 objs/nginx "$RTMP_PREFIX/sbin/nginx"
for d in logs hls client_body_temp proxy_temp fastcgi_temp uwsgi_temp scgi_temp; do
install -d -o www -g www -m 0750 "$RTMP_PREFIX/$d"
done4. Create the isolated streaming configuration Save the following complete file as /opt/adminsforum-rtmp-lab-20261019/conf/nginx.conf, for example with nano. If you chose another prefix, update both absolute hls paths too. Keep the rtmp block at the top level, alongside http; do not paste it into an aaPanel website's server block. Code: worker_processes 1;
pid logs/nginx.pid;
error_log logs/error.log info;
events { worker_connections 128; }
rtmp {
server {
listen 127.0.0.1:11935;
application live {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
allow play 127.0.0.1;
deny play all;
hls on;
hls_path /opt/adminsforum-rtmp-lab-20261019/hls;
hls_fragment 2s;
hls_playlist_length 8s;
}
application denied {
live on;
deny publish all;
deny play all;
}
}
}
http {
access_log logs/access.log;
default_type application/octet-stream;
server {
listen 127.0.0.1:18085;
server_name localhost;
location /hls/ {
alias /opt/adminsforum-rtmp-lab-20261019/hls/;
types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; }
add_header Cache-Control "no-store" always;
autoindex off;
}
location = /stat { rtmp_stat all; }
location / { return 404; }
}
}5. Validate, start and inspect Code: runuser -u www -- "$RTMP_PREFIX/sbin/nginx" -p "$RTMP_PREFIX/" -c conf/nginx.conf -t
runuser -u www -- "$RTMP_PREFIX/sbin/nginx" -p "$RTMP_PREFIX/" -c conf/nginx.conf
ss -lntp | grep -E '11935|18085'
curl -sS http://127.0.0.1:18085/stat6. Publish a short synthetic stream This generates a small test picture and tone without using copyrighted sample media or a camera. Leave it running while you inspect the output from a second SSH session: Code: ffmpeg -hide_banner -loglevel error -re -f lavfi -i testsrc2=size=320x180:rate=10 -f lavfi -i sine=frequency=440:sample_rate=44100 -t 30 -c:v libx264 -preset ultrafast -tune zerolatency -threads 1 -pix_fmt yuv420p -g 20 -c:a aac -b:a 64k -f flv rtmp://127.0.0.1:11935/live/test7. Verify the playlist and video segments While the publisher is active, wait for several seconds and run: Code: curl -i http://127.0.0.1:18085/hls/test.m3u8
ls -lh /opt/adminsforum-rtmp-lab-20261019/hls/
curl -sS http://127.0.0.1:18085/statCode: curl -f http://127.0.0.1:18085/hls/test-0.ts -o /tmp/af-stream-test.ts
ffprobe -v error -show_entries stream=codec_name,codec_type,width,height -of json /tmp/af-stream-test.ts
ffmpeg -v error -i /tmp/af-stream-test.ts -f null -8. Access the private test from your own computer For a player test, an SSH local tunnel can forward the localhost HTTP listener: Code: ssh -N -L 18085:127.0.0.1:18085 YOUR_SSH_USER@YOUR_VPS_IP9. Troubleshoot by symptom
10. Stop and roll back this lab Stop the publisher with Ctrl+C, then stop only this instance: Code: runuser -u www -- /opt/adminsforum-rtmp-lab-20261019/sbin/nginx -p /opt/adminsforum-rtmp-lab-20261019/ -c conf/nginx.conf -s quit
ss -lntH '( sport = :11935 or sport = :18085 )'
/www/server/nginx/sbin/nginx -tWhat is still needed for public broadcasting? A public deployment needs publisher authentication, protected statistics/control endpoints, valid playback HTTPS, monitored disk/bandwidth usage, a supervised service and realistic load tests. A stream name alone is not authentication. This article deliberately keeps the test private; it does not claim public OBS access, browser playback, CDN delivery, RTMPS or a production security audit. About aaPanel's Add Module screen The native panel approach recompiles its managed Nginx and must preserve all existing build options and update behavior. We did not perform that replacement on this working server. The corrected principle is to prepare the RTMP source in the prefix script, provide --add-module with its absolute path, and let the Nginx build run configure. Do not copy the older recipe's stray ./configure into that prefix script. A native-panel rebuild deserves a separate disposable-server test. References: original aaPanel discussion, module source, official Nginx downloads. All diagrams and test media in this article are original AdminsForum lab material. |