Skip to content

Installing nginx for Avalon

Carrick Rogers edited this page Oct 10, 2016 · 23 revisions
  1. Install prerequisites:
  • Generalized Install:
    1. distro-specific build tools
    2. libssl (with dev headers)
    3. libpcre3 (with dev headers)
    4. zlib (with dev headers)
    5. mediainfo
    6. ffmpeg
  • RedHat/CentOS Specific:
    1. sudo su - root
    2. yum groupinstall 'Development Tools'
    3. yum install openssl openssl-devel
    4. yum install pcre pcre-devel
    5. yum install zlib zlib-devel
    6. yum install mediainfo
    7. yum install ffmpeg
    8. As one large command: yum groupinstall 'Development Tools' && yum install -y openssl openssl-devel pcre pcre-devel zlib zlib-devel mediainfo ffmpeg
  1. Checkout and build nginx with rtmp and vod modules:

    1. Clone nginx, rtmp, and vod:
    2. git clone https://github.com/nginx/nginx.git && cd nginx && git checkout $(git describe --tags) && cd ..
    3. git clone https://github.com/arut/nginx-rtmp-module.git && cd nginx-rtmp-module && git checkout $(git describe --tags) && cd ..
    4. git clone https://github.com/kaltura/nginx-vod-module.git && cd nginx-vod-module && git checkout $(git describe --tags) && cd ..
    5. Build nginx:
    6. cd nginx
    7. ./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_module
    8. sudo make install
  2. Create a user called nginx with read-access rights to your streaming files.

    1. Create the user: usseradd nginx
    2. Grant read-access to nginx:
      1. Locate your streaming files:
      • In an already configured avalon open config/avalon.yml and look in the streaming block for content_path
      • If you have not yet installed avalon, you will need to create a location. When installed avalon make sure your content_path in the streaming block within config/avalon.yml points to this location.
      1. Either set read permissions for all users the content_path directory or add ngnix to 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.
  3. Create your nginx conf:

    1. If not root: sudo su - root
    2. mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.original && touch /usr/local/nginx/conf/nginx.conf
    3. Insert the content example conf file into /usr/local/nginx/conf/nginx.conf using your text editor of choice.
    4. In /usr/local/nginx/conf/nginx.conf edit: * PATH/TO/STREAMFILES to point to the content_path from config/avalon.yml. This needs to changed in two locations, the rtmp block and and the http block. * AVALON_BASE_URL with the url of your avalon rails app. This needs to changed in two locations, the rtmp block and and the http block. * The listen port in the http block. 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) Change resolver in the http block from 8.8.8.8 to a local DNS server if desired.
  4. Start nginx /usr/local/nginx/sbin/nginx

    Creating 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.

  5. In your avalon app open config/avalon.yml and under the proper environment (development, test, or production) set the server and _base paths in the streaming block (the ports are the ones set in nginx.conf):

  • server: nginx
  • rtmp_base: rtmp://server.library.somewhere.edu:1935/avalon
  • http_base: http://server.library.somewhere.edu:1817/avalon
  1. 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:

  2. Log into the server hosting your Avalon rails app

  3. Go to the root directory of your Avalon rails app and run rails c if you are in the development environment. If you are in test or production run: cd script && RAILS_ENV=environment bundle exec script/rails c replacing environment with the applicable environment.

  4. Once the rails console has launched run Derivative.find_each { |d| d.set_streaming_locations!; d.save } to update your derivatives.

  5. Restart your Avalon rails app.