Introduction to my Nginx usage
First on configuration:
work_processes4; events{work_connections1024x768;} http{includeMime.types;Default_typeApplication/octet-stream;Sendfile on;Keepalive_timeout $; server{Listen the;server_namelocalhost Location/{RoothtmlInsexIndex.html index.htm; } Location/hls{alias/tmp/app; }Error_page -502503504/50x.html; Location=/50x.html{Roothtml }}}rtmp{server{Listen1935;chunk_size4000;Applicationliaortmp{Live on; }Applicationhls{Live on;HLS on;Hls_path/tmp/app;hls_frament15s; } } }
Interpretation of the configuration
Work_processes: The START process, usually set to the number of CPUs equal.
Work_connections: Maximum number of concurrent links for a single background worker process session
HTTP Server configuration
- sendndfile: Specifies whether Nginx calls the Sendfile function (zero copy mode) to output the file, and for normal applications, it must be set to On, if used for downloading applications such as disk IO heavy load applications, can be set to off to balance disk and network I/O processing speed, reduce system uptime.
- Keepalive_timeout: Connection time-out
- Server
- listen: Configure which port to listen
- server_name: Define the use of XXX access, that is, the IP domain name
- loaction/: Default Request
- Error_page and immediately following location: Define error page
- Location/hls: Define request HLS, I am declaring here that if the request HLS stream is to be appended to the playback address M3 U8,hls slices from the/tmp/
app
, which the app defines for itself
Configuration of rtmp push-streaming server
- Listen: Listening port
- Application liaortmp: Configuring rtmp normal push Flow request here
- Application Liaohls: Configure the rtmp push flow request here, play in HLS mode, slice in/tmp/
app
, where it corresponds exactly to the HTTP configuration above, what the app writes here, and what it writes at http
- Live on: Toggle Live mode, which is a one-to-many broadcast
- HLS on: Switch HLS in application
- Hls_path: Slice Storage Address
- Hls_fragment: Slice size, set HLS segment length, default is 5 seconds
At this point, the simple configuration of Nginx has been completed, the/usr/local/conf/nginx.conf is stored in the above configuration.
- Give an example (about
app
)
- RTMP push streaming and rtmp playback
- Push Stream Address: Rtmp://x.x.x.x:1935/liaortmp/liao
- Play Address: Rtmp://x.x.x.x:1935/liaortmp/liao
- RTMP push Stream and HLS live
- Push Stream Address: Rtmp://x.x.x.x:1935/liaohls/liao
- Play Address: Rtmp://x.x.x.x:80/hls/liao
liao
is arbitrary that can be replaced.
Reference
1. Nginx Configuration File Detailed description
2. Nginx RTMP Module Nginx-rtmp-module instruction detailed
The above describes the Nginx configuration Rtmp server to implement RTMP and HLS live, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.