Installing Nginx on Ubuntu 18.04 was easy peasy, adding the RTMP module has resulted in less success for me. Preferably up-to-date version. I have been using the Nginx RTMP on Previous Ubuntu versions with no problem.

I consider myself a beginner to Linux, learning on the go!
Usage: Custom mobile streaming.

  • 1
    How did you attempt to add the RTMP module? Installing libnginx-mod-rtmp, or attempting to put a dynamic-module separately-compiled version of the module into your existing NGINX environment?
    – Thomas Ward
    May 10 '18 at 20:43

nginx-rtmp module can be installed directly from the Ubuntu 18.04 repository

sudo apt install libnginx-mod-rtmp

The latest version of nginx supports dynamic modules, make sure the statement to load the module is added in the nginx.conf:

load_module "modules/ngx_rtmp_module.so";

reference: https://stackoverflow.com/questions/36554405/how-to-enable-dynamic-module-with-an-existing-nginx-installation

  • This worked for me as well. Updated repos, installed nginx with sudo apt install nginx, then installed libnginx-mod-rtmp. The module was automatically picked up and loaded in nginx.conf, and nginx restarted after install :)
    – Araho
    Oct 10 '19 at 20:54

You cannot install the 'latest' RTMP module without recompiling NGINX at the same time, currently.

However, the RTMP module is available in the repositories already, but it is not called in by any specific NGINX flavor anymore. You will need to install the module with libnginx-mod-rtmp - this will install the RTMP module that was compiled alongside NGINX when the packages were built, and then you should just need to restart and configure NGINX to use the RTMP module and its settings. (beyond the scope of this question)

sudo apt install libnginx-mod-rtmp
sudo systemctl stop nginx
sudo systemctl start nginx

The three aforementioned commands will be able to install the RTMP module. While it might not be the absolute latest of the code, it should provide most of the features that the RTMP module supports.

  • There are 4 nginx packages: common, light, full, and extras. Common doesn't even install the actual daemon. ALL of the other 3 give me the same error: nginx: [emerg] "rtmp" directive is not allowed here. Seems to be a bug in the packaging or versions somewhere. It's like it's not loading the rtmp module, but I also can't seem to find an nginx-related command to check which modules are actually loaded by the runtime. Jan 6 '19 at 16:34
  • 1
    @DavidKrider nginx-common doesn't contain binaries because of the large number of non-dynamic modules that vary between the different flavors. You must install light, full, or extras to get the daemon, or core if you're using the Ubuntu versions of the package. You can get the list of modules available by checking nginx -V and checking /etc/nginx/modules-enabled for what dynamic modules are enabled. (FYI I'm the maintainer of the NGINX package in Ubuntu, if you have concerns about how things're packaged direct your concerns to me directly or open a bug against nginx)
    – Thomas Ward
    Jan 6 '19 at 17:59
  • 1
    @DavidKrider further, nginx-common contains data that is common across all the flavors available in the repositories - basically, configuration files, etc. that're common to all the variants of nginx 'flavors'
    – Thomas Ward
    Jan 6 '19 at 18:01
  • I understand the packaging, even though it surprised me that common didn't install the daemon. The problem is that even though I install the "extras" package, and the rtmp module, and I can see the rtmp module in the list when doing nginx -V, I still get the error above, as if the server doesn't understand the "rtmp" directive in the config file. Jan 10 '19 at 1:33

after add the rtmp module

 sudo apt install libnginx-mod-rtmp

for restarting nginx as service you can try

 sudo service nginx restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.