此文转自http://www.bwcsc.net/?q=node/483
目前已经有不少视频网站使用了H264(.Mp4)格式的视频文件,本文介绍如何在lighttpd-1.4.22下编译模块来支持Mp4文件的拖动功能
1、创建下载目录
|
mkdir –p /back/soft/lighttpd |
2、下载lighttpd-1.4.22
|
cd /back/soft/lighttpd wget http://www.lighttpd.net/download/lighttpd-1.4.22.tar.gz |
3、下载H264视频模块
|
svn export http://h264.code-shop.com/svn/h264/tags/mod_h264_streaming-2.0/lighttpd-1.4.18 lighttpd-1.4.18 svn export --force http://h264.code-shop.com/svn/h264/tags/mod_h264_streaming-2.0/mp4split lighttpd-1.4.18/src |
4、拷贝源文件
|
cp lighttpd-1.4.18/src/moov.* lighttpd-1.4.22/src/ cp lighttpd-1.4.18/src/mod_h264_streaming.c lighttpd-1.4.22/src/ |
5、修改Make文件
修改lighttpd-1.4.22/src/Makefile.am文件
|
vi Makefile.am 查找/mod_flv |
在
|
lib_LTLIBRARIES += mod_flv_streaming.la mod_flv_streaming_la_SOURCES = mod_flv_streaming.c mod_flv_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined mod_flv_streaming_la_LIBADD = $(common_libadd) |
下面增加如下代码
|
#add by zhao 090608 lib_LTLIBRARIES += mod_h264_streaming.la mod_h264_streaming_la_SOURCES = mod_h264_streaming.c moov.c mod_h264_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined mod_h264_streaming_la_LIBADD = $(common_libadd) |
保存退出
#vi Makfile.in 查找/mod_flv
mod_flv_streaming_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_mod_flv_streaming_la_OBJECTS = mod_flv_streaming.lo
mod_flv_streaming_la_OBJECTS = $(am_mod_flv_streaming_la_OBJECTS)
mod_flv_streaming_la_LINK = $(LIBTOOL) –tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) –mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(mod_flv_streaming_la_LDFLAGS) $(LDFLAGS) -o $@
下面增加以下内容
mod_h264_streaming_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_mod_h264_streaming_la_OBJECTS = mod_h264_streaming.lo moov.lo
mod_h264_streaming_la_OBJECTS = $(am_mod_h264_streaming_la_OBJECTS)
mod_h264_streaming_la_LINK = $(LIBTOOL) –tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) –mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(mod_h264_streaming_la_LDFLAGS) $(LDFLAGS) -o $@
查找下一下mod_flv(在VI模式下按n键)
SOURCES = ….的$(mod_flv_streaming_la_SOURCES) 后面增加
$(mod_h264_streaming_la_SOURCES)
DIST_SOURCES = …的$(mod_flv_streaming_la_SOURCES) \后面增加
$(mod_h264_streaming_la_SOURCES) \
lib_LTLIBRARIES = $(am__append_1) mod_flv_streaming.la后面增加_h264_streaming.la如下
lib_LTLIBRARIES = $(am__append_1) mod_flv_streaming.la mod_h264_streaming.la \
在mod_flv_streaming_la_SOURCES = mod_flv_streaming.c
mod_flv_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_flv_streaming_la_LIBADD = $(common_libadd)
下面增加
mod_h264_streaming_la_SOURCES = mod_h264_streaming.c moov.c
mod_h264_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_h264_streaming_la_LIBADD = $(common_libadd)
在mod_flv_streaming.la: $(mod_flv_streaming_la_OBJECTS) $(mod_flv_streaming_la_DEPENDENCIES)
$(mod_flv_streaming_la_LINK) -rpath $(libdir) $(mod_flv_streaming_la_OBJECTS) $(mod_flv_streaming_la_LIBADD) $(LIBS)
下面增加
mod_h264_streaming.la: $(mod_h264_streaming_la_OBJECTS) $(mod_h264_streaming_la_DEPENDENCIES)
$(mod_h264_streaming_la_LINK) -rpath $(libdir) $(mod_h264_streaming_la_OBJECTS) $(mod_h264_streaming_la_LIBADD) $(LIBS)
在
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_flv_streaming.Plo@am__quote@
下面增加
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_h264_streaming.Plo@am__quote@
保存退出
6、编译安装
|
#cd lighttpd-1.4.22 #./configure –prefix=/usr/local/lighttpd #make && make instll |
查看/usr/local/lighttpd/lib目录下是否存在mod_h264_streaming.la、mod_h264_streaming.so文件,如果存在,则表示安装成功
7、修改配置文件
#cd /usr/local/lighttpd/lighttpd
#mkdir etc
#cd /back/soft/lighttpd-1.4.22/doc
#cp lighttpd.conf /usr/local/lighttpd/etc
#cd /usr/local/lighttpd/etc
#vi lighttpd.conf 查找/ server.modules 更改增加红字部分如下:
server.modules = (
# “mod_rewrite”,
# “mod_redirect”,
# “mod_alias”,
“mod_access”,
# “mod_cml”,
# “mod_trigger_b4_dl”,
# “mod_auth”,
# “mod_status”,
# “mod_setenv”,
# “mod_fastcgi”,
# “mod_proxy”,
# “mod_simple_vhost”,
# “mod_evhost”,
# “mod_userdir”,
# “mod_cgi”,
# “mod_compress”,
# “mod_ssi”,
# “mod_usertrack”,
# “mod_expire”,
# “mod_secdownload”,
“mod_flv_streaming”,
“mod_h264_streaming”,
# “mod_rrdtool”,
“mod_accesslog” )
server.port = 80
flv-streaming.extensions = ( “.flv” )
h264-streaming.extensions = ( “.mp4” )
保存退出
8、增加启动脚本
#cd /back/soft/lighttpd-1.4.22/doc
#cp rc.lighttpd.redhat /etc/init.d/lighttpd
#vi /etc/init.d/lighttpd
修改第25,29行如下所示
24 if [ -z “$LIGHTTPD_CONF_PATH” ]; then
25 LIGHTTPD_CONF_PATH= “/usr/local/lighttpd/etc/lighttpd.conf”
26 fi
27
28 prog=”lighttpd”
29 lighttpd=”/usr/local/lighttpd/sbin/lighttpd”
30 RETVAL=0
保存退出
/etc/init.d/lighttpd start 启动服务
ps -ef|grep lighttpd 查看是否启动成功,如果出现下面信息,表示启动成功
root 26231 1 0 02:19 ? 00:00:00 /usr/local/lighttpd264/sbin/lighttpd -f /usr/local/lighttpd264/etc/lighttpd.conf
[root@linux01 lighttpd-1.4.22]# make
make all-recursive
make[1]: Entering directory /root/src/lighttpd-1.4.22'
Making all in src
make[2]: Entering directory
/root/src/lighttpd-1.4.22/src’
Makefile:867: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
make[2]: Leaving directory /root/src/lighttpd-1.4.22/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
/root/src/lighttpd-1.4.22′
make: *** [all] Error 2
错误解决办法
vi /back/soft/lighttpd-1.4.22/src/Makefile
将867行的$(mod_fastcgi_la_LINK) -rpath $(libdir) $(mod_fastcgi_la_OBJECTS) $(mod_fastcgi_la_LIBADD) $(LIBS)前面的空格删除,按一下Tab键,保存.重新编译通过