-
Notifications
You must be signed in to change notification settings - Fork 51
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 - root
yum groupinstall 'Development Tools'
yum install openssl openssl-devel
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install mediainfo
yum 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_module
sudo make install
-
Create a user called
nginx
with 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.yml
and look in thestreaming
block forcontent_path
- If you have not yet installed avalon, you will need to create a location. When installed avalon make sure your
content_path
in thestreaming
block withinconfig/avalon.yml
points to this location.
- Either set read permissions for all users the
content_path
directory or addngnix
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.
- 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.conf
using your text editor of choice. - In
/usr/local/nginx/conf/nginx.conf
edit: *PATH/TO/STREAMFILES
to point to thecontent_path
fromconfig/avalon.yml
. This needs to changed in two locations, thertmp
block and and thehttp
block. *AVALON_BASE_URL
with the url of your avalon rails app. This needs to changed in two locations, thertmp
block and and thehttp
block. * Thelisten
port in thehttp
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) Changeresolver
in thehttp
block from8.8.8.8
to a local DNS server if desired.
- If not root:
-
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.
-
In your avalon app open
config/avalon.yml
and under the proper environment (development
,test
, orproduction
) set theserver
and_base
paths in the streaming block (the ports are the ones set innginx.conf
):
server: nginx
rtmp_base: rtmp://server.library.somewhere.edu:1935/avalon
http_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 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. -
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.