常青树 发表于 2018-11-15 09:57:16

Nginx 学习笔记(三)Nginx + flv

  环境 ubuntu 12.04
  搭建视频服务器,播放flv和MP4文件,webserver用Nginx,编译增加http_flv_module;播放器使用开源的jw player。
  nginx在ubuntu上用apt-get安装默认编译选项里面没有http_flv_module,所以需要重新编译一遍,顺便升级到了最新的稳定版1.2.7
  编译nginx需要下载openssh包,PCRE包,zlib包
  下载相应包文件后
  


[*]#增加http_flv_module
[*]./configure --with-http_flv_module --prefix=/usr/local/nginx
[*]make
[*]sudo make install
  

  不报错的话 nginx已经编译完成,编译后的文件结构如下:
  


[*]nginx path prefix: "/usr/local/nginx"
[*]
[*]nginx binary file: "/usr/local/nginx/sbin/nginx"
[*]
[*]nginx configuration prefix: "/usr/local/nginx/conf"
[*]
[*]nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
[*]
[*]nginx pid file: "/usr/local/nginx/logs/nginx.pid"
[*]
[*]nginx error log file: "/usr/local/nginx/logs/error.log"
[*]
[*]nginx http access log file: "/usr/local/nginx/logs/access.log"
[*]
[*]nginx http client request body temporary files: "client_body_temp"
[*]
[*]nginx http proxy temporary files: "proxy_temp"
[*]
[*]nginx http fastcgi temporary files: "fastcgi_temp"
[*]
[*]nginx http uwsgi temporary files: "uwsgi_temp"
[*]
[*]nginx http scgi temporary files: "scgi_temp"
  

  建立软连接
  


[*]sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
  

  输入 sudo nginx 启动nginx
  修改/usr/local/nginx/conf/nginx.conf
  


[*]#在http{}块内增加
[*]location ~ \.flv {
[*]                flv;
[*]      }
  

  即可增加对flv模块的支持,重新启动nginx
  


[*]#重新启动Nginx
[*]sudo /usr/sbin/nginx -s reload
[*]#或者采用
[*]sudo /usr/sbin/nginx -s stop
[*]sudo nginx
  

  下载jw player,开源软件,专业版和高级版需要付费,下载地址
  


[*]http://www.longtailvideo.com/jw-player/
  

  将下载的包解压,见jwplayer文件夹全部上传到网站根目录下
  在网页中引用
  


[*]
  

  然后增加播放器
  


[*]Loading the player...
[*]
[*]
[*]    jwplayer("myElement").setup({
[*]      file: "/uploads/myVideo.mp4",
[*]      image: "/uploads/myPoster.jpg"
[*]    });
[*]
  



页: [1]
查看完整版本: Nginx 学习笔记(三)Nginx + flv