Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a VOD server based on http protocol by nginx

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how nginx builds a VOD server based on http protocol. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Nginx builds VOD server based on http protocol

1. Download and install nginx stable Edition, http://nginx.org/en/download.html

2. Install the related library pcre zlib openssl first to see if it is installed.

Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

Http://zlib.net/zlib-1.2.8.tar.gz

Http://www.openssl.org/source/openssl-1.0.1f.tar.gz

[root@localhost vsftpd] # rpm-qa pcre

Pcre-7.8-7.el6.i686

3. Download nginx_mod_h364_streaming-2.2.7.tar.gz

Http://h364.code-shop.com/download/nginx_mod_h364_streaming-2.2.7.tar.gz

Extract the nginx_mod_h364_streaming-2.2.7.tar.gz and add the flv,mp4 module. Extract to a directory at the same level as the nginx source.

4, download nginx-rtmp-module

Https://github.com/arut/nginx-rtmp-module

Unzip nginx-rtmp-module-master

5, because flv and http are included with nginx, there is no need to download this module.

. / configure\

-- sbin-path=/usr/local/sbin\

-- add-module=../nginx-rtmp-module-1.0.2\

-- with-http_ssl_module\

-- add-module=../nginx_mod_h364_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

. / configure-- add-module=/usr/server/nginx_mod_h364_streaming-2.2.7-- sbin-path=/usr/local/sbin-- with-debug

Select the compilation options you need

There are still many compilation options for Nginx, which are basically customized locations and modules, which are:

1)-- sbin-path=/usr/local/sbin

Compiling from source Nginx will be installed in the / usr/local/nginx directory (you can use the parameter-- prefix= to specify the location you want), and then the bin file will be placed in / usr/local/nginx/sbin/nginx, which is relatively clear, but different from our general habits.

(as programmers, we are more used to looking for bin files under / usr/local / sbin)

2)-- with-http_ssl_module

Mainly provide https access support

Make

Make install

5,make

May encounter problem 1

/ root/nginx_mod_h364_streaming-2.2.7/src/ngx_http_streaming_module.c: In function 'ngx_streaming_handler':

/ root/nginx_mod_h364_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_h364_streaming_module.o] Error 1

Make [1]: Leaving directory `/ root/nnginx-1.5.9'

Make: * * [build] Error 2

Then delete or comment out the following code in the src/ngx_http_streaming_module.c file

/ * TODO: Win32 * /

If (r-> zero_in_uri)

{

Return NGX_DECLINED

}

May encounter problem 2

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c: in the function 'esds_read':

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:377:16: error: the variable 'stream_priority' is set but not used [- Werror=unused-but-set-variable]

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:376:12: error: the variable 'stream_id' is set but not used [- Werror=unused-but-set-variable]

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c: in the function 'stsd_parse_vide':

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:529:22: error: the variable 'level_indication' is set but not used [- Werror=unused-but-set-variable]

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:528:22: error: the variable 'profile_compatibility' is set but not used [- Werror=unused-but-set-variable]

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:527:22: error: the variable 'profile_indication' is set but not used [- Werror=unused-but-set-variable]

.. / nginx_mod_h364_streaming-2.2.7/src/mp4_reader.c:526:22: error: the variable 'configuration_version' is set but not used [- Werror=unused-but-set-variable]

Cc1: all warnings being treated as errors

Make [1]: * * [objs/addon/src/mp4_reader.o] error 1

Solution:

# vim objs/Makefile (modify the objs/Makefile file to remove the "- Werror"), and then compile normally.

6, make install

7. Configuring nginx.conf is mainly server.

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. Start nginx and create the / usr/local/nginx/html/flv_file/ directory.

Cd / usr/local/nginx

Start. / nginx

Gracefully close. / nginx-s quit

Quickly close. / nginx-s stop

Nginx-s reload: reloading takes effect after configuration modification

Nginx-s reopen: reopen the log file

Nginx-t-c / path/to/nginx.conf tests whether the nginx configuration file is correct

/ usr/local/sbin/nginx-c / usr/local/nginx/conf/nginx.conf-s reload

9. Upload mp4 video file CY.mp4

Write a html test. Look at the previous article using jwplayer to test, but I have been reporting jwplayer udefined here.

Loading the player...

This is how nginx builds a VOD server based on http protocol. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report