close

Nginx 最近還蠻紅的,連 Garlic 都跟我提過,所以最近就把這東西裝起來試看看。

網站:

  • http://nginx.org/
  • http://wiki.nginx.org/Main

一、環境 ( on SUSE 11 )

首先環境要有安裝 pcre-devel  zlib-devel  libopenssl-devel (看錯誤訊息寫少啥就裝啥,哈哈)

因為 SUSE 有 zypper ,所以直接 zypper in xxxx 就好了,超方便的。


二、

到 Ngnix 下載 nginx-0.8.54

http://nginx.org/download/nginx-0.8.54.tar.gz

到 h264.code-shop.com 下載 H264 Streaming Module for Nginx (version 2)

http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

接著解壓

# tar -zxvf nginx-0.8.54.tar.gz
# tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz


我在 nginx-0.8.54 裡面再建一個資料匣 modules ,然後把 nginx_mod_h264_streaming-2.2.7 放到裡面。

所以安裝的指令就是如下:

# cd nginx-0.8.54
# ./configure --prefix=/home/nginx --add-module=modules/nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_stub_status_module --with-debug

啟用 debug connection : --with-debug

啟用 flv module : --with-http_flv_module

啟用 server status 頁面 : --with-http_stub_status_module


三、開始安裝

執行

# make

但卻出現了錯誤訊息

modules/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 `/tmp/chingwei/nginx-0.8.54.tmp'
make: *** [build] Error 2

 

如下圖:

解法:到他說的檔案 ngx_http_streaming_module.c 的第 158 行

# vi modules/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

把 158 行看到的

/* TODO: Win32 */
if (r->zero_in_uri) {
    return NGX_DECLINED;
}

Mark 起來。

重新再 make; make install 就成功了。


四、設定

接著就是設定的部份了

# vi /home/nginx/conf/nginx.conf
...
server {
       listen       80;
       server_name  localhost;

       root /home/www/cw_dev/;

       access_log  /home/logs/nginx/host.access.log  main;

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

       location ~\.flv$ {
               flv;
       }

       location ~\.mp4$ {
               mp4;
       }
       error_page  404              /404.html;

       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   html;
       }
}
...

基本上這樣就可以跑了。

讓 Server 啟動吧。

/home/nginx/sbin/nginx

放幾個flv & mp4 的影片在 server 上,然後開始測試吧。

 

結論:安裝還挺簡單的,而且外掛 Module 也不難。仔細看它的 Wiki ,還可以發現很多好玩的東西,還不錯。

 

arrow
arrow
    全站熱搜

    Ching-Wei 發表在 痞客邦 留言(0) 人氣()