-
Notifications
You must be signed in to change notification settings - Fork 52
Installing nginx for Avalon
- Install prerequisites:
- Generalized Install:
- distro-specific build tools
- libssl (with dev headers)
- libpcre3 (with dev headers)
- zlib (with dev headers)
- mediainfo
- ffmpeg
- RedHat/CentOS Specific:
sudo su - rootyum groupinstall 'Development Tools'yum install openssl openssl-develyum install pcre pcre-develyum install zlib zlib-develyum install mediainfoyum install ffmpeg- As one large command:
yum groupinstall 'Development Tools' && yum install -y openssl openssl-devel pcre pcre-devel zlib zlib-devel mediainfo ffmpeg
-
Checkout and build nginx with rtmp and vod modules:
- Clone nginx, rtmp, and vod:
git clone https://github.com/nginx/nginx.git && cd nginx && git checkout $(git describe --tags) && cd ..git clone https://github.com/arut/nginx-rtmp-module.git && cd nginx-rtmp-module && git checkout $(git describe --tags) && cd ..git clone https://github.com/kaltura/nginx-vod-module.git && cd nginx-vod-module && git checkout $(git describe --tags) && cd ..- Build nginx:
cd nginx./auto/configure --with-file-aio --with-cc-opt="-O3" --add-module=../nginx-rtmp-module --add-module=../nginx-vod-module --with-http_auth_request_module --with-http_sub_modulesudo make install
-
Create a user called
nginxwith read-access rights to your streaming files.- Create the user:
usseradd nginx - Grant read-access to nginx:
- Locate your streaming files:
- In an already configured avalon open
config/avalon.ymland look in thestreamingblock forcontent_path - If you have not yet installed avalon, you will need to create a location. When installed avalon make sure your
content_pathin thestreamingblock withinconfig/avalon.ymlpoints to this location.
- Either set read permissions for all users the
content_pathdirectory or addngnixto a group that has read permissions to the directory. Typical avalon installs have this directory owned by the matterhorn user with read permission to all users.
- Create the user:
-
Create your nginx conf:
- If not root:
sudo su - root mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.original && touch /usr/local/nginx/conf/nginx.conf- Insert the content example conf file into
/usr/local/nginx/conf/nginx.confusing your text editor of choice. - In
/usr/local/nginx/conf/nginx.confedit: *PATH/TO/STREAMFILESto point to thecontent_pathfromconfig/avalon.yml. This needs to changed in two locations, thertmpblock and and thehttpblock. *AVALON_BASE_URLwith the url of your avalon rails app. This needs to changed in two locations, thertmpblock and and thehttpblock. * Thelistenport in thehttpblock. Select a port that does not impact other services you are running. If you are not running anything on 1817, the default is fine. * (Optional) Changeresolverin thehttpblock from8.8.8.8to a local DNS server if desired.
- If not root:
-
Start nginx
/usr/local/nginx/sbin/nginxCreating a startup/init script for nginx is distro-specific, but nginx itself is easy to control from the command line, so creating a start/stop/reload/restart script shouldn't be difficult. You can find init scripts for many distros here.
-
In your avalon app open
config/avalon.ymland under the proper environment (development,test, orproduction) set theserverand_basepaths in the streaming block (the ports are the ones set innginx.conf):
server: nginxrtmp_base: rtmp://server.library.somewhere.edu:1935/avalonhttp_base: http://server.library.somewhere.edu:1817/avalon
-
Update preexisting content if applicable. If you have streaming content in your directory (due to previously using another streaming server for this Avalon instance) you need to update it. If this is a fresh install, you can skip this step. To update your content:
-
Log into the server hosting your Avalon rails app
-
Go to the root directory of your Avalon rails app and run
rails cif you are in the development environment. If you are in test or production run:cd script && RAILS_ENV=environment bundle exec script/rails creplacing environment with the applicable environment. -
Once the rails console has launched run
Derivative.find_each { |d| d.set_streaming_locations!; d.save }to update your derivatives. -
Restart your Avalon rails app.