nginx安装-添加MP4播放模块

nginx安装很简单,但是有的时候是已经安装的nginx ,升级增加nginx 模块功能。

最近公司要nginx增加一个可以播放 MP4的模块,安装还算顺利,不说废话上命令。

1 安装依赖

yum install -y make zilb-devel openssl-devel pcre-devel libaio libaio-devel

wget http://nginx.org/download/nginx-1.10.3.tar.gz

#创建用户和用户组

groupadd www
useradd -s /sbin/nologin -M -g www www

#解压

tar -zxvf nginx-1.10.3.tar.gz

#进入nginx安装目录

cd nginx-1.10.3

#配置 编译安装

./configure --user=www --group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-file-aio \
--with-http_flv_module \
make && make install

#进入nginx sbin启动

cd /usr/local/nginx/sbin

./nginx

至此安装完毕

下面是在原有nginx 基础上 增加MP4播放功能模块

首先下载 nginx_mod_h264_streaming-2.2.7.tar.gz

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

tar -xvf nginx_mod_h264_streaming-2.2.7.tar.gz

#重点来了

vim nginx_mod_h264_streaming-2.2.7

NGINX=$(HOME)/nginx-1.10.3/ #这里修改自己的nginx版本

#vim nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

以下

TODO: Win32

if (r->zero_in_uri)

{

return NGX_DECLINED;

}

改成

/*

TODO: Win32

if (r->zero_in_uri)

{

return NGX_DECLINED;

}

*/

#然后再次进入nginx的安装目录

cd nginx-1.10.3

./configure --user=www --group=www
--add-module=/usr/local/src/nginx_mod_h264_streaming-2.2.7 \
--prefix=/usr/local/nginx \
--with-http_mp4_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-file-aio \
--with-http_flv_module \

#注意这里只编译 不安装

make

#修改nginx配置文件,强烈建议修改备份,我这里是直接添加nginx Vhost的方式 直接在nginx的conf 下的conf.d 下面直接添加下面的server

server {
listen 80;
server_name 你的域名;
root html;
index index.html index.htm;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location ~.(jpg|png|gif)$ {
root /data/www/oul;
}
location ~
.*.mp4$ {
root /data/www/oul;
mp4;
}
}

注意下 这个关键步骤

备份您的

cd /usr/local/nginx/sbin

cp nginx nginx.bak

复制新编译好的nginx执行文件

cp /root/cd nginx-1.10.3/objs/nginx /usr/local/nginx/sbin/nginx

找一个MP4视频文件放到nginx网站目录默认是/usr/local/nginx/html 下面

重启 nginx

有个坑 ,注意修改nginx的vhost的根访问文件夹 必须重启 reload 不起作用!!!

另外 nginx如果增加其他功能模块的过程大多这样 注意 make 只编译不要执行安装备份还你要修改的文件。

原文地址:http://blog.51cto.com/2687949/2108206

时间: 2024-08-01 13:23:25

nginx安装-添加MP4播放模块的相关文章

nginx安装配置+清缓存模块安装

经过一段时间的使用,发现nginx在并发与负载能力方面确实优于apache,现在已经将大部分站点从apache转到了nginx了.以下是nginx的一些简单的安装配置. 环境 操作系统:CentOS.RedHat IP地址:192.168.1.202 下载软件包 # mkdir /usr/local/src/tarbag # mkdir /usr/local/src/software # cd /usr/local/src/tarbag/ Nginx # wget http://www.ngin

nginx之三:nginx安装配置+清缓存模块安装

经过一段时间的使用,发现 nginx 在并发与负载能力方面确实优于 apache,现在已经将大部分站点从 apache 转到 了 nginx 了.以下是 nginx 的一些简单的安装配置. 环境 操作系统:CentOS.RedHat IP 地址:192.168.1.202 下载软件包 # mkdir /usr/local/src/tarbag# mkdir /usr/local/src/software# cd /usr/local/src/tarbag/# wget http://www.ng

Nginx整合mp4,flv模块

注: nginx 1.1.3之后已经默认支持mp4,flv模块,无须第三方模块支持. 操作步骤: 1:解压,编译nginx,编译添加mp4,flv模块: # tar -zxvf nginx-1.3.14.tar.gz # cd nginx-1.3.14 # ./configure  # ./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-select_module --with-poll_module

nginx编译安装和未编译模块的添加

安装nginx Yum 安装 参考http://nginx.org/en/linux_packages.html 编译安装nginx 系统首先要安装gcc* 包以及一些依赖包 [[email protected] tool]# wget http://nginx.org/download/nginx-1.8.0.tar.gz [[email protected] tool]# tar xf nginx-1.8.0.tar.gz -C /usr/local/src/ [[email protect

安装成功的nginx如何添加未编译安装模块

原已经安装好的nginx,现在需要添加一个未被编译安装的模块举例说明:安装第三方的ngx_cache_purge模块(用于清除指定URL的缓存)nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so 1.wget http://labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz tar -zxvf ngx_cache_purge-2.0.tar.gz cd /data0/software/nginx-1.1.10 2.

给已安装的NGINX添加新的模块

给已安装的NGINX添加新的模块 2018-11-16 14:02:45   Visit  0 使用nginx -V,查看当前nginx的信息,包括版本号和configure编译配置信息 版本号 1.14.1configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-pa

Nginx为已安装nginx动态添加模块

本篇文章主要介绍了Nginx之为已安装nginx动态添加模块的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧这里以安装第三方ngx_http_google_filter_module模块为例 nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so 下载第三方扩展模块ngx_http_google_filter_module cd /data/software/ # git clone https://github.com/cuber

nginx安装第三方模块

原已经安装好的nginx,现在需要添加一个未被编译安装的模块 举例说明:安装第三方的ngx_cache_purge模块(用于清除指定URL的缓存) nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so 1.wget http://labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz tar -zxvf ngx_cache_purge-2.0.tar.gz cd /data0/software/nginx-1.1.10

Nginx 动态添加模块

Nginx动态添加模块 1.首先查看现在已经编译的模块 /usr/local/nginx/sbin/nginx -V 2.下载需要编译的模块 wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip 新模块:--add-module=/data/package/nginx_tcp_proxy_module-master/ #模块存放路径 3.进入nginx安装目录 进行重新编译,需要加上之前已经编译过的