指引网

当前位置: 主页 > 服务器 > Lighttpd >

Lighttpd搭建Flv可拖拽媒体服务器的教程

来源:网络 作者:佚名 点击: 时间:2017-08-31 00:42
[摘要] 为大家介绍如何在Lighttpd上搭建Flv可拖拽媒体服务器,有需要的朋友,可以参考下。

播放视频有两种方式:
方式1,以http协议方式来访问视频文件,这种方式的缺点是不能从视频特定的帧位置进行播放,必须从头开始。常用的方案是Appache+前端flv播放器。
方式2,搭建专门的复杂的流媒体服务器,优点是视频支持拖拽播放,缺点是这种服务器搭建复杂,配置要求也比较高,而且运行其上的程序必须是某种语言。

本文为大家介绍如何配置flv播放器,使用jw player和lighttpd搭建一个在线的flv流媒体播放功能。
而且lighttpd也是有mod_flv_streaming模块来支持flv视频的流播放功能。

所需软件:
1、pcre-8.21.zip (http://www.pcre.org/)
2、lighttpd-1.4.30.tar.gz (http://www.lighttpd.net/download/)
3、jw player (http://www.longtailvideo.com/players/jw-flv-player/)

一、安装Pcre和Lighttpd
 

复制代码 代码示例:

#-----配置yum源-------#
#wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
#rpm –ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

#-----安装pcre-------#
#tar xf pcre-8.21.tar.gz
#cd pcre-8.21
#./configure
#make
#make install

######lighttpd的编译安装 ######
#tar xf lighttpd-1.4.19.tar.gz
#cd lighttpd-1.4.19
#./configure --prefix=/usr/local/lighttpd
#make
#make install

########lighttpd的配置文件、用户组和用户的配置#######
#mkdir /usr/local/lighttpd/etc

#mkdir /usr/local/lighttpd/etc/conf.d
#cp doc/config/lighttpd.conf  /usr/local/lighttpd/etc

#cp doc/rc.lighttpd /etc/init.d/lighttpd

#cd doc/config/conf.d/* /usr/local/lighttpd/etc/conf.d/
#groupadd lighttpd
#useradd -g lighttpd lighttpd
########启动脚本参数修改,启动脚本在本文下半部分提供 #######
#vi /etc/init.d/lighttpd
修改LIGHTTPD_CONF_PATH =/etc/sysconfig/lighttpd为/usr/local/lighttpd/etc/lighttpd.conf
修改lighttpd =/usr/sbin/lighttpd为/usr/local/lighttpd/sbin/lighttpd

二、lighttpd的配置和使用
server.document-root 改为你的网站的根目录(如/www)
server.errorlog 改为错误日志的路径(如/usr/local/lighttpd/logs/error.log)
accesslog.filename 改为访问日志的路径(如/usr/local/lighttpd/logs/access.log)
modules.conf       lighttpd模块配置文件
server.modules      根据需要启动模块
include "conf.d/fastcgi.conf"  fastcgi文件文件

1、#-----####/usr/local/lighttpd/etc/lighttpd.conf配置文件#-----#
 

复制代码 代码示例:

var.log_root    = "/var/log"
var.server_root = "/var/www"
var.state_dir   = "/var/run"
var.home_dir    = "/var/lib/lighttpd"
var.conf_dir    = "/etc/lighttpd"
var.vhosts_dir  = server_root + "/vhosts"
var.cache_dir   = "/var/cache/lighttpd"
var.socket_dir  = home_dir + "/sockets"
include "modules.conf"
server.port = 80
server.username  = "lighttpd"
server.groupname = "lighttpd"
server.document-root = server_root + "/htdocs"
server.pid-file = state_dir + "/lighttpd.pid"
server.errorlog             = log_root + "/error.log"
include "conf.d/access_log.conf"
include "conf.d/fastcgi.conf"
server.event-handler = "linux-sysepoll"
server.network-backend = "linux-sendfile"
server.max-fds = 2048
server.stat-cache-engine = "simple"
server.max-connections = 1024
index-file.names += (
  "index.xhtml", "index.html", "index.htm", "default.htm", "index.php"
)

url.access-deny             = ( "~", ".inc" )
$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" )
include "conf.d/mime.conf"
include "conf.d/dirlisting.conf"
server.follow-symlink = "enable"
server.upload-dirs = ( "/var/tmp" )

2、#-----######模块配置文件:/usr/local/lighttpd/etc/modules.conf#-----
 

复制代码 代码示例:
server.modules = (
"mod_access",
"mod_flv_streaming")
flv-streaming.extensions = ( ".flv" )
include "conf.d/secdownload.conf"

3、#-----#######fastcgi.conf 的配置文件#-----######
 

复制代码 代码示例:
server.modules += ( "mod_fastcgi" )
fastcgi.server = ( ".php" =>
                   ( "php-tcp" =>
                     (
                       "host" => "127.0.0.1",
                       "port" => 9000,
                       "check-local" => "disable",
                       "broken-scriptfilename" => "enable",
                     )
                  ),
                )

4、#-----####Secdownload防盗链设置#-----###
 

复制代码 代码示例:

server.modules+ = ("mod_secdownload") # 加上该模块
secdownload.secret = "abc" # 密钥,在你后面都程序要用到
secdownload.document-root = "/home/www/down/" # 真实文件路径,尽可能在web服务器之外
secdownload.uri-prefix = "/flv/" # 访问时uri前缀
secdownload.timeout = 10 # 超时时间设置,过期后会显示找不到页面

server.modules += ( "mod_secdownload" )
secdownload.document-root = server_root + "/downloads"
secdownload.secret = "abc"
secdownload.timeout = 60
secdownload.uri-prefix = "/flv/"
...
 

详细的配置内容,参考:《Lighttpd搭建Flv可拖拽媒体服务器》

最终实现的访问效果如下图所示:
flv媒体服务顺

------分隔线----------------------------