madhawa

NGINX-HLS-UBuntu

Dec 22nd, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. apt-get install libpcre3-dev autoconf2.13 libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libmysql++-dev libfreetype6-dev libt1-dev libc-client-dev libevent-dev libxml2-dev libtool libmcrypt-dev make libgeoip-dev psmisc unzip
  2.  
  3. adduser --system --no-create-home --disabled-login --disabled-password --group www
  4. mkdir /var/lib/nginx
  5. mkdir -p /var/www/default/public_html
  6. chown www:www -R /var/www/default/public_html
  7.  
  8. cd /usr/src/
  9. wget http://nginx.org/download/nginx-1.7.6.tar.gz
  10. tar -xzf nginx-1.7.6.tar.gz
  11.  
  12. cd /usr/src/
  13. wget https://github.com/arut/nginx-rtmp-module/archive/master.zip -O master.zip
  14. unzip master.zip
  15.  
  16. cd /usr/src/nginx-1.*
  17.  
  18.  
  19. ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=www --group=www --with-poll_module --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access_log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --http-scgi-temp-path=/var/lib/nginx/scgi --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-pcre --with-md5-asm --with-sha1-asm --with-zlib-asm=pentium --add-module=/usr/src/nginx-rtmp-module-master
  20.  
  21. make && make install
  22.  
  23. nano /etc/init.d/nginx
  24. -----
  25. #! /bin/sh
  26.  
  27. ### BEGIN INIT INFO
  28. # Provides: nginx
  29. # Required-Start: $all
  30. # Required-Stop: $all
  31. # Default-Start: 2 3 4 5
  32. # Default-Stop: 0 1 6
  33. # Short-Description: starts the nginx web server
  34. # Description: starts nginx using start-stop-daemon
  35. ### END INIT INFO
  36.  
  37. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  38. DAEMON=/usr/sbin/nginx
  39. NAME=nginx
  40. DESC=nginx
  41.  
  42. test -x $DAEMON || exit 0
  43.  
  44. # Include nginx defaults if available
  45. if [ -f /etc/default/nginx ] ; then
  46. . /etc/default/nginx
  47. fi
  48.  
  49. set -e
  50.  
  51. . /lib/lsb/init-functions
  52.  
  53. case "$1" in
  54. start)
  55. echo -n "Starting $DESC: "
  56. start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  57. --exec $DAEMON -- $DAEMON_OPTS || true
  58. echo "$NAME."
  59. ;;
  60. stop)
  61. echo -n "Stopping $DESC: "
  62. start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
  63. --exec $DAEMON || true
  64. echo "$NAME."
  65. ;;
  66. restart|force-reload)
  67. echo -n "Restarting $DESC: "
  68. start-stop-daemon --stop --quiet --pidfile \
  69. /var/run/$NAME.pid --exec $DAEMON || true
  70. sleep 1
  71. start-stop-daemon --start --quiet --pidfile \
  72. /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
  73. echo "$NAME."
  74. ;;
  75. reload)
  76. echo -n "Reloading $DESC configuration: "
  77. start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
  78. --exec $DAEMON || true
  79. echo "$NAME."
  80. ;;
  81. status)
  82. status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
  83. ;;
  84. *)
  85. N=/etc/init.d/$NAME
  86. echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
  87. exit 1
  88. ;;
  89. esac
  90.  
  91. exit 0
  92. -----
  93. chmod 755 /etc/init.d/nginx
  94. update-rc.d -f nginx defaults
  95. cd /usr/src
  96.  
  97.  
  98. mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.back
  99. nano /etc/nginx/nginx.conf
  100. -----
  101. user www;
  102. worker_processes 1;
  103.  
  104. events {
  105. worker_connections 1024;
  106. }
  107.  
  108. http {
  109. include mime.types;
  110. default_type application/octet-stream;
  111.  
  112. sendfile on;
  113. keepalive_timeout 65;
  114. gzip on;
  115.  
  116. server {
  117. listen 8080;
  118. server_name localhost;
  119.  
  120. location / {
  121. root /var/www/default/public_html/;
  122. }
  123.  
  124. # rtmp stat
  125. location /stat {
  126. rtmp_stat all;
  127. rtmp_stat_stylesheet stat.xsl;
  128. }
  129. location /stat.xsl {
  130. # you can move stat.xsl to a different location
  131. root /usr/src/nginx-rtmp-module-master;
  132. }
  133.  
  134. # rtmp control
  135. location /control {
  136. rtmp_control all;
  137. }
  138.  
  139. error_page 500 502 503 504 /50x.html;
  140. location = /50x.html {
  141. root html;
  142. }
  143.  
  144. location /hls {
  145. types {
  146. application/vnd.apple.mpegurl m3u8;
  147. }
  148. alias /run/shm;
  149. }
  150. }
  151. }
  152.  
  153. rtmp {
  154. server {
  155. listen 1935;
  156. ping 30s;
  157. notify_method get;
  158.  
  159. # Live
  160. application live {
  161. live on;
  162. hls on;
  163. hls_path /run/shm;
  164. hls_fragment 10s;
  165. hls_continuous on;
  166. hls_nested on;
  167. hls_fragment_naming sequential;
  168. hls_fragment_slicing aligned;
  169. }
  170. }
  171. }
  172. -----
  173. service nginx restart
  174.  
  175. to access
  176. http://<ip>:8080/hls/<streamname>.m3u8
Advertisement
Add Comment
Please, Sign In to add comment