Nginx : Add/Enable mp4 module
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 make
then make install
but it didn't worked. Also I am afraid that this recompile process will delete all my conf and domain settings.
Solution 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)
Solution 2:
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;
}