1、安装pcre-8.33.tar.bz2
#tar -xvf 1.pcre-8.33.tar.bz2
#cd pcre-8.33/
#./configure
#make && make install
2、安装openssl-1.0.1h.tar.gz
#tar -xvf openssl-1.0.1h.tar.gz
# cd openssl-1.0.1h/
#./config
#make && make install
3、添加mp4支持模块
下载 http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
#tar -xvf 3.nginx_mod_h264_streaming-2.2.7.tar.gz
4、安装nginx
#tar -xvf 4.nginx-1.7.1.tar.gz
#cd nginx-1.7.1/
#./configure --add-module=/HLS/nginx_mod_h264_streaming-2.2.7 --with-http_ssl_module --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module
注意:nginx安装时,报错/HLS/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:,此时需要修改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; //} |
5、nginx配置文件 nginx.conf
#user www www;
worker_processes 30;
error_log /usr/local/nginx/logs/error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
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 8888;
server_name 192.168.245.133;
root /WebFiles/;
limit_rate_after 5m; ####在flv视频文件下载了5M以后开始限速
limit_rate 512k; ####速度限制为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;
}
}
}
nginx搭建flv、mp4流媒体服务