Serving progressive download video files (such as MP4 and FLV) with seeking capabilities directly from Apache on a cPanel/WHM server requires compiling custom Apache modules: mod_flvx for FLV streaming and mod_h264_streaming for pseudo-streaming H.264/MP4 files.
1. Persistent Hook Script
To ensure modules are compiled and reinstalled automatically whenever cPanel runs EasyApache, add the build commands to /scripts/after_apache_make_install:
#!/bin/bash
cd /usr/local/src
# Compile mod_flvx
wget http://people.apache.org/~pquerna/modules/mod_flvx.c
/usr/local/apache/bin/apxs -i -c mod_flvx.c
# Compile mod_h264_streaming
wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
cd mod_h264_streaming-2.2.7
./configure --with-apxs='/usr/local/apache/bin/apxs'
make && make install
# Update cPanel Apache configuration distiller
/usr/local/cpanel/bin/apache_conf_distiller --update
Ensure the hook script is executable:
chmod +x /scripts/after_apache_make_install
2. Apache Global Configuration
Add the module declarations and file extension handlers to /usr/local/apache/conf/includes/pre_virtualhost_global.conf:
LoadModule h264_streaming_module modules/mod_h264_streaming.so
<IfModule mod_h264_streaming.c>
AddHandler h264-streaming.extensions .mp4
</IfModule>
LoadModule flvx_module modules/mod_flvx.so
<IfModule mod_flvx.c>
AddHandler flv-stream .flv
</IfModule>
3. Rebuild with EasyApache
Execute EasyApache through WHM or the command line to finalize the build. Once complete, video seeking will work seamlessly over HTTP.
No comments:
Post a Comment