2

Is there a way to enable this module on nginx ? http://wiki.nginx.org/HttpMp4Module

I have already many domains running on nginx and I can't just remove it and rebuilt everything .

I tried downloading latest nginx, and do ./configure --with-http_mp4_module and makethen make install but it didn't worked. Also I am afraid that this recompile process will delete all my conf and domain settings.

2 Answers 2

17

Install:

$ sudo apt-get install nginx-extras

Example configuration:

location /video/ {
    mp4;
    mp4_buffer_size       1m;
    mp4_max_buffer_size   5m;
    mp4_limit_rate        on;
    mp4_limit_rate_after  30s;
}
1
  • just be aware mp4_limit_rate and mp4_limit_rate_after directives are not available in the free nginx version
    – 6bytes
    May 14, 2022 at 16:21
1

Firstly, backup your nginx config folder (/etc/nginx) - if your configs are valuable to you, then you certainly need an extra copy in case anything goes wrong. That said, most installations do not overwrite the existing configs.

Secondly, for a proper configure line, run nginx -V (with your working nginx), and then add the additional configure statement, there are likely other configuration parameters that are relevant to your setup. (This will also let you verify whether or not the module is already compiled into the version you are running.) (Also, you said it 'didn't work' - why? What was the error?). The default nginx configure statement (x86) is:

--prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx \
--with-http_ssl_module --with-http_realip_module --with-http_addition_module \
--with-http_sub_module --with-http_dav_module --with-http_flv_module \
--with-http_mp4_module --with-http_gzip_static_module \
--with-http_random_index_module --with-http_secure_link_module \
--with-http_stub_status_module --with-mail --with-mail_ssl_module \
--with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -march=i386 -mtune=i686'

Finally, if you don't have specific optimizations in place (e.g. you have removed certain modules, etc) you can use the nginx repository (available for RHEL/CentOS, Debian/Ubuntu) - the published binaries include the module you are looking for (as per the config statement above) and the repository makes it easier to maintain (the downside being the lack of customization, but sometimes, it is a worthwhile price to pay).

The repository version does not overwrite your configurations, but if there are new config files it will add them - this has been an issue for some configurations with the newer versions, since /etc/nginx/conf.d/default.conf is added - which specifies an additional server that may not be compatible with existing configurations. (You can just rename this file, or even copy back your entire /etc/nginx folder to restore your old config)

7
  • The OS is Ubuntu 11.10 x64. I did run nginx -V and mp4 module wasn't there. Also there was no error. OK I posted on pastbin the whole message output from the beginning (./configure) to end (make install) pastebin.com/RNVgri7a
    – xperator
    Dec 19, 2011 at 15:27
  • Looks like the compile succeeded - I would suggest you probably have two versions of nginx - one from before, and the new one you compiled. The new one is in /usr/local/nginx/sbin/nginx. Run which nginx to see if the default one matches that, and use the full path to verify that your install succeeded (/usr/local/nginx/sbin/nginx -V). If things work, you just need to modify your init script to point to the new binary.
    – cyberx86
    Dec 19, 2011 at 15:37
  • Oops! That means I got 2 nginx installed ? I think I should get rid of one of them. I don't them to have conflict in anyway. It will be messy like this. which nginx prints /usr/sbin/nginx. Is it possible to compile the new one over the existing one ? or just copy necessary files to the existing? or move the new one over the existing while keeping the current configuration? How can I solve this ?
    – xperator
    Dec 19, 2011 at 15:45
  • You can install over the previous version by specifying the /sbin path in the configure command with --sbin-path=/usr/sbin/nginx. Be careful however, the configuration of the new nginx is completely different from your original one (at very least, all the paths differ - including the config path). I'd highly advice either a) copy the configure statement you get from nginx -V (the currently working one) and add your --sbin-path=/usr/sbin/nginx --with-http_mp4_module (which will then install over the old one); or better yet use the nginx repository.
    – cyberx86
    Dec 19, 2011 at 15:58
  • Ok, I tried copy all nginx -V statements and add them to ./configure plus those two you mentioned. But I am getting a lot of error regarding this or that has not be found or is not installed. How can I use the nginx repository itself to overcome this problem ? I have no idea how to do that.
    – xperator
    Dec 19, 2011 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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