Ubuntu x86 64 settup nginx rtmp server

经常搭建nginx服务器,但是好像每次的情况都不同,这次详细记录这个过程:
平台:unbutu 10.04 内核:2.6.32-33-generic
1, 编译环境搭建。
sudo apt-get install g++
sudo apt-get -y install autoconf automake build-essential libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libssl-dev
2, 建立如下下载脚本:getfile.sh
-------------------getfile.sh start here---------------------------------------------------
wget http://sourceforge.net/projects/pcre/files/pcre/8.32/pcre-8.32.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
wget http://nginx.org/download/nginx-1.5.9.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git
tar xvf pcre-8.32.tar.gz
tar xvf openssl-1.0.1e.tar.gz
tar xvf nginx-1.5.9.tar.gz
tar xvf zlib-1.2.8.tar.gz
tar xvf nginx_mod_h264_streaming-2.2.7.tar.gz
-------------------getfile.sh end here---------------------------------------------------

3, 编译openssl,这部是必须的,否则后面编译会fail的
cd openssl-1.0.1e #:notice the version
编译静态库

sudo chmod u+x ./config
./config --prefix=/usr/local --openssldir=/usr/local/opensll
make
sudo make install

编译动态库

./config shared --prefix=/usr/local --openssldir=/usr/local/opensll
make clean
make
sudo make install



4, 在nginx-1.5.9建立配置文件脚本nginx_configure.sh
----------------------------nginx_configure.sh start here-------------------------------------------------
#!/bin/sh

./configure \
--prefix=/usr/local/nginx/ \
--add-module=../nginx-rtmp-module \
--with-http_ssl_module \
--add-module=../nginx_mod_h264_streaming-2.2.7 \
--with-pcre=../pcre-8.32 \
--with-zlib=../zlib-1.2.8  \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_mp4_module  \
--with-cc-opt='-O3'
----------------------------nginx_configure.sh end here-------------------------------------------------

5, 进入nginx-1.5.9
执行./nginx_configure.sh
make -j8
出错
-------------------------------the error log start here----------------------------------------------------
In file included from ../nginx_mod_h264_streaming-2.2.7/src/ngx_http_h264_streaming_module.c:2:
../nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
../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]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/media/zangcf/works/works/nginx/x86/nginx_x86/nginx-1.5.9'
make: *** [build] Error 2
-------------------------------the error log end here-------------------------------------------------------
gedit ../nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

找到如下
  /* TODO: Win32 */
  if (r->zero_in_uri)
  {
    return NGX_DECLINED;
  }
注释掉

make -j8

pass

sudo make install

6, 修改config文件
sudo cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
sudo gedit /usr/local/nginx/conf/nginx.conf
--------------------------nginx.conf start here----------------------------------------------------------------------
user  root;
worker_processes  2;

#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;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen      80 default;
        server_name  localhost;
        autoindex            on;
        autoindex_exact_size on;
        root    /var/wwwroot;
        index   index.html index.htm index.php;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~* \.php$ {
            fastcgi_index  index.php;
            client_max_body_size 64m;
            fastcgi_pass   unix:/data/data/android.php-fpm/tmp/php-fpm.socket;
            fastcgi_param  SCRIPT_FILENAME  /data/data/android.wwwroot$fastcgi_script_name;
            include        fastcgi_params;
        }

       location ~ \.flv$ {
                         flv;
                        }
       location ~ \.mp4$ {
                         mp4;
                        }


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000  default;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen     443 default;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


rtmp {
    server {
        listen 1935;

        chunk_size 4096;

        application myapp {
            live on;
        }
    }
}

----------------------------------------------nginx.conf end here--------------------------------------

7, 测试




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值