nginx搭建基于http协议的视频点播服务器
生活随笔
收集整理的這篇文章主要介紹了
nginx搭建基于http协议的视频点播服务器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1,于由自己的服務器上已經安裝好nginx(具體安裝方法見我的另一篇文章,Linux中安裝nginx),所以不再安裝。
?
2,下載nginx_mod_h264_streaming-2.2.7.tar.gz(自己在網上搜吧)。
?
3,安裝pcre,先看有沒有安裝。
?????
[root@localhost vsftpd]#?rpm -qa pcre???? pcre-7.8-7.el6.i686 已經安裝(上篇加rtmp模塊的時候已經安裝了) 4,解壓nginx_mod_h264_streaming-2.2.7.tar.gz,添加flv,mp4模塊。解壓到和nginx源碼同級的目錄。然后./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_mp4_module 因為flv 和http是nginx自帶的所以不用下載這個模塊。 5,make 可能遇到問題1
???? ?/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
??? ?/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
?????make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
???? make[1]: Leaving directory `/root/nnginx-1.5.9'
???? make: *** [build] Error 2
???? 那么將src/ngx_http_streaming_module.c文件中以下代碼刪除或者是注釋掉就可以了 6, make install 7,配置 nginx.conf
?
??
#user? nobody;worker_processes? 1; #error_log? logs/error.log;
#error_log? logs/error.log? notice;
#error_log? logs/error.log? info; #pid??????? logs/nginx.pid;
events {
??? worker_connections? 1024;
} #include? nginx.conf-rtmp; http { include?????? mime.types; default_type? application/octet-stream; log_format main? '$remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$gzip_ratio"'; keepalive_timeout? 60; server_names_hash_bucket_size? 128; client_header_buffer_size??? 32k; large_client_header_buffers? 4 32k; access_log off; gzip on; gzip_min_length? 1100; gzip_buffers???? 4 8k; gzip_types?????? text/plain; output_buffers?? 1 32k; postpone_output? 1460; client_header_timeout? 3m; client_body_timeout??? 3m; send_timeout?????????? 3m; sendfile??????????????? on; tcp_nopush????????????? on; tcp_nodelay???????????? on; ###################################################################### server {
????
??????????? listen???????8999;
????
??????????? server_name??192.168.1.104;
????
??????????? root????/usr/local/nginx/html/flv_file/;
????
??????????? limit_rate_after 5m;???
??????????? limit_rate 512k;????????
????
????
??????????? index?? index.html;
????
??????????? charset utf-8;
????
??????????? location ~ \.flv {
????
??????????????? flv;
????
??????????? }
????
??????????? location ~ \.mp4$ {
???????????????????? mp4;
??????????? }
????
????
??????????? error_page?? 500 502 503 504? /50x.html;
????
??????????? location = /50x.html {
????
??????????????? root?? html;
????
??????????? }
????} } 8,啟動nginx,創建/usr/local/nginx/html/flv_file/目錄。
?
9,上傳mp4視頻文件CY.mp4。 10,寫個html測試。看之前的文章用jwplayer來測試,但是我這邊一直報jwplayer udefined。 <!DOCTYPE html><div id="container">Loading the player ...</div>
<video src="http://192.168.1.104:8999/CY.mp4" controls="controls" width="50%" height="50%">
</video>
?
總結
以上是生活随笔為你收集整理的nginx搭建基于http协议的视频点播服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到大蟒蛇进家里来了预示着什么
- 下一篇: 企业如何寻找最合适的托管数据中心,以维持