Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://habrahabr.ru/post/162237/
- http://firstwiki.ru/index.php/%D0%94%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5_%D0%BC%D0%BE%D0%B4%D1%83%D0%BB
- %D0%B5%D0%B9_nginx_%D0%B2_Linux_%28Debian/Ubuntu/CentOS%29
- https://github.com/sergey-dryabzhinsky/nginx-rtmp-module
- https://github.com/mattpepin/nginx-rtmp-module
- http://nginx.org/download/nginx-1.2.1.tar.gz
- -----------------------------------------------------
- Ставить этот вариант:
- Качаем:
- https://github.com/arut/nginx-rtmp-module
- https://github.com/arut/nginx-rtmp-module/archive/master.zip
- Качаем:
- Полная версия nginx для ubuntu
- http://packages.ubuntu.com/trusty/httpd/nginx-full
- http://archive.ubuntu.com/ubuntu/pool/main/n/nginx/nginx_1.4.6.orig.tar.gz
- http://archive.ubuntu.com/ubuntu/pool/main/n/nginx/nginx_1.4.6-1ubuntu3.7.debian.tar.gz
- Распаковаем nginx_1.4.6.orig.tar.gz
- Добавляем в папку modules модули из nginx_1.4.6-1ubuntu3.7.debian.tar.gz
- Заменяем модуль headers-more-nginx-module скачанным отсюда https://github.com/openresty/headers-more-nginx-module
- Ставим:
- sudo apt-get install nginx nginx-extras
- Проверяем версию и установленные библиотеки
- nginx -V
- Должно получиться нечто похожее на:
- root@UbuntuSRV01:/etc/nginx# nginx -V
- nginx version: nginx/1.4.6
- built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
- TLS SNI support enabled
- configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -
- D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-
- path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-
- path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-
- path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-
- uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-
- http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --
- with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-
- http_perl_module --with-http_random_index_module --with-http_secure_link_module --with-http_spdy_module --with-http_sub_module
- --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/home/firs/nginx-1.4.6/modules/headers-more-nginx-
- module --add-module=/home/firs/nginx-1.4.6/modules/nginx-auth-pam --add-module=/home/firs/nginx-1.4.6/modules/nginx-cache-purge
- --add-module=/home/firs/nginx-1.4.6/modules/nginx-dav-ext-module --add-module=/home/firs/nginx-1.4.6/modules/nginx-
- development-kit --add-module=/home/firs/nginx-1.4.6/modules/nginx-echo --add-module=/home/firs/nginx-1.4.6/modules/ngx-
- fancyindex --add-module=/home/firs/nginx-1.4.6/modules/nginx-http-push --add-module=/home/firs/nginx-1.4.6/modules/nginx-lua
- --add-module=/home/firs/nginx-1.4.6/modules/nginx-upload-progress --add-module=/home/firs/nginx-1.4.6/modules/nginx-upstream-
- fair --add-module=/home/firs/nginx-1.4.6/modules/ngx_http_substitutions_filter_module --add-module=/home/firs/nginx-rtmp-
- module-master
- Сохраним вывод команды nginx -V в какой-нибудь текстовый редактор - эта информация нам пригодится при конфигурировании. Видим,
- что версия nginx у нас установлена 1.2.1 - скачиваем такую же версию:
- # wget http://nginx.org/download/nginx-1.2.1.tar.gz
- Распакуем архив и перейдём в папку nginx-1.2.1:
- # tar –xvf nginx-1.2.1.tar.gz
- # cd nginx-1.2.1
- Далее, для сборки, нам потребуется установить в систему дополнительные пакеты.
- Для Debian/Ubuntu выполняем:
- # aptitude install build-essential
- Конфигурируем
- ./configure --add-module=/path/to/nginx-rtmp-module
- При конфигурации указываем полные пути до модулей, например:
- ./configure --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -
- D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-
- path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-
- path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-
- path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-
- uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-
- http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --
- with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-
- http_perl_module --with-http_random_index_module --with-http_secure_link_module --with-http_spdy_module --with-http_sub_module
- --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/home/firs/nginx-1.4.6/modules/headers-more-nginx-
- module --add-module=/home/firs/nginx-1.4.6/modules/nginx-auth-pam --add-module=/home/firs/nginx-1.4.6/modules/nginx-cache-purge
- --add-module=/home/firs/nginx-1.4.6/modules/nginx-dav-ext-module --add-module=/home/firs/nginx-1.4.6/modules/nginx-
- development-kit --add-module=/home/firs/nginx-1.4.6/modules/nginx-echo --add-module=/home/firs/nginx-1.4.6/modules/ngx-
- fancyindex --add-module=/home/firs/nginx-1.4.6/modules/nginx-http-push --add-module=/home/firs/nginx-1.4.6/modules/nginx-lua
- --add-module=/home/firs/nginx-1.4.6/modules/nginx-upload-progress --add-module=/home/firs/nginx-1.4.6/modules/nginx-upstream-
- fair --add-module=/home/firs/nginx-1.4.6/modules/ngx_http_substitutions_filter_module --add-module=/home/firs/nginx-rtmp-
- module-master
- В процессе конфигурирования возможно будут появляться ошибки.
- Ошибка:
- ./configure: error: the HTTP rewrite module requires the PCRE library.
- You can either disable the module by using --without-http_rewrite_module
- option, or install the PCRE library into the system, or build the PCRE library
- statically from the source with nginx by using --with-pcre=<path> option.
- исправляется установкой libpcre++-dev:
- # sudo apt-get install libpcre++-dev
- SSL modules
- sudo apt-get install libssl-dev
- GeoIP module
- sudo apt-get install libgeoip-dev
- HTTP XSLT module
- sudo apt-get install libxslt1-dev
- HTTP image filter module requires the GD library
- sudo apt-get install libgd2-noxpm-dev
- Ошибка ./configure: error: C compiler gcc is not found
- apt-get install libc6-dev
- ngx_http_lua_module
- sudo apt-get install libluajit-5.1-dev
- /Build/NginX/nginxmodules/nginx_http_auth_pam/1.2/ngx_http_auth_pam_module.c:13:31: fatal error: security/pam_appl.h: No such
- file or directory
- sudo apt-get install libpam-dev
- /usr/bin/ld: cannot find -lperl
- libperl-dev
- После успешного окончания конфигурирования увидим на экране что-то вроде:
- nginx path prefix: "/etc/nginx"
- nginx binary file: "/etc/nginx/sbin/nginx"
- nginx configuration prefix: "/etc/nginx"
- nginx configuration file: "/etc/nginx/nginx.conf"
- nginx pid file: "/var/run/nginx.pid"
- nginx error log file: "/var/log/nginx/error.log"
- nginx http access log file: "/var/log/nginx/access.log"
- nginx http client request body temporary files: "/var/lib/nginx/body"
- nginx http proxy temporary files: "/var/lib/nginx/proxy"
- nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
- Теперь можно собрать бинарник nginx - выполняем 2 команды:
- # make
- # make install
- Последним этапом является настройка для запуска новой версии nginx в автоматическом режиме. Вероятнее всего установленный nginx
- из репозиториев лежит в папке /usr/share/nginx, новая версия установлена где-то в другом месте. Запускающий скрипт для nginx
- стандартно хранится по адресу: /usr/sbin/nginx. Необходимо переименовать этот файл и установить симлинк на файл запуска в новой
- версии:
- user@name: cd /usr/sbin
- user@name: mv nginx nginx_old
- user@name: ln -s /path/to/new/version/nginx-1.6.2/sbin/nginx nginx
- user@name: nginx -V
- user@name: nginx -t
- user@name: service nginx restart
- ------------------------------------------------------------------------------------
- Авторизация стримера
- ?user=user&pass=pass
- http://phpez.com/uncategorized/4.html
- nginx.conf
- http {
- limit_conn_zone $server_name zone=perserver:10m;
- # nginx default configs...
- server {
- listen 80;
- server_name localhost;
- location /stat {
- rtmp_stat all;
- rtmp_stat_stylesheet stat.xsl;
- }
- location /stat.xsl {
- root /usr/local/src/nginx-rtmp-module;
- }
- location /control {
- rtmp_control all;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50.html {
- root html;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
- include fastcgi_params;
- }
- location /hls {
- limit_conn perserver 10;
- root /tmp;
- }
- }
- }
- rtmp {
- server {
- listen 1935;
- ping 30s;
- notify_method get;
- buflen 5s;
- drop_idle_publisher 30s;
- max_connections 55;
- application myapp {
- live on;
- # запись видео
- #record all;
- #record_path /mnt/rec;
- #record_suffix _%d-%b-%y_%H-%M-%S.flv;
- hls on;
- hls_path /tmp/hls;
- hls_fragment 5s;
- on_publish http://localhost:80/on_publish.php;
- }
- }
- on_publish.php
- <?php
- // ?user=user&pass=pass
- $user = isset($_GET['user']) ? $_GET['user'] : '';
- $pass = isset($_GET['pass']) ? $_GET['pass'] : '';
- if (empty($user) || empty($pass)) {
- echo "wrong query input";
- header('HTTP/1.0 404 Not Found');
- exit();
- }
- $saveuser = user;
- $savepass = pass;
- if (strcmp($user, $saveuser) == 0 && strcmp($pass, $savepass) == 0) {
- echo "Username and Password OK";
- } else {
- echo "Username or Password wrong";
- header('HTTP/1.0 404 Not Found');
- exit();
- }
- ?>
- Использование:
- FMS URL:
- rtmp://localhost:1935/myapp
- mystream?user=rtmp&pass=12345
- on_publish.php положить в каталог /usr/share/nginx/html
- ---------------------------------------------------------------------------------------------
- Multi-worker statistics and control with nginx "per-worker-listener" patch
- http://nginx-rtmp.blogspot.ru/2013/06/multi-worker-statistics-and-control.html
- https://github.com/arut/nginx-patches
- ---------------------------------------------------------------------------------------------
- Модуль статистики для nginx
- --with-http_stub_status_module
- Конфиг:
- location /basic_status {
- stub_status;
- }
- ---------------------------------------------------------------------------------------------
- Блокируем обновления nginx
- 1) Смотрим расширенный статус требуемого пакета:
- dpkg --get-selections | grep nginx
- 2) Блокируем обновления пакета (ставим на него "Hold"):
- sudo apt-mark hold nginx nginx-common nginx-extras
- 3) Смотрим результат:
- dpkg --get-selections | grep nginx
- -------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement