1. 程式人生 > >直播推流之nginx伺服器搭建

直播推流之nginx伺服器搭建

nginx依賴pcre和zlib和openssl,分別去這兩個官方網站下載最新的版本.
pcre下載頁面>
Screenshot from 2016-06-07 21:14:40.png

zlib下載頁面>
Screenshot from 2016-06-07 21:12:32.png

openssl下載頁面>
Screenshot from 2016-06-07 21:11:17.png

最後統一拷貝到某個目錄下
Screenshot from 2016-06-07 21:18:22.png

用命令解壓3個檔案
tar -xzvf xxx.tar.gz
tar -jxvf xxx.tar.bz2

到官網下載nginx>

Screenshot from 2016-06-08 08:49:51.png

同樣用tar命令解壓
解壓完後進入cd解壓出來的目錄

[email protected]:~/Soft/nginx_station/nginx-1.10.1$ sudo ./configure --prefix=/usr/local/nginx --with-pcre=/home/wangxiong/Soft/nginx_station/pcre2-10.20
--with-zlib=/home/wangxiong/Soft/nginx_station/zlib-1.2.8 --with-openssl=/home/wangxiong/Soft/nginx_station/openssl-1.0.1t --with-http_ssl_module checking for OS + Linux 3.16.0-71-generic x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) checking for
gcc -pipe switch ... found checking for -Wl,-E switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for gcc builtin 64 bit byteswap ... found checking for unistd.h ... found checking for inttypes.h ...
found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for O_PATH ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for sched_setaffinity() ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for nobody group ... not found checking for nogroup group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for SO_SETFIB ... not found checking for SO_REUSEPORT ... found checking for SO_ACCEPTFILTER ... not found checking for IP_RECVDSTADDR ... not found checking for IP_PKTINFO ... found checking for IPV6_RECVPKTINFO ... found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE ... found checking for TCP_FASTOPEN ... found checking for TCP_INFO ... found checking for accept4() ... found checking for eventfd() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint32_t ... found checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for pwritev() ... found checking for sys_nerr ... found checking for localtime_r() ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found creating objs/Makefile Configuration summary + using PCRE library: /home/wangxiong/Soft/nginx_station/pcre2-10.20 + using OpenSSL library: /home/wangxiong/Soft/nginx_station/openssl-1.0.1t + md5: using OpenSSL library + sha1: using OpenSSL library + using zlib library: /home/wangxiong/Soft/nginx_station/zlib-1.2.8 nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"

–prefix引數指定nginx安裝的目錄,–with-pcre和 –with-zlib以及–with-openssl分別對應自己的解壓目錄,–with-http_ssl_module是為了防止找不到sha1庫,這裡會用openssl的sha1庫!

配置完成後,執行make和make和make install,完成編譯工作!
編譯出現的問題:
[1]
Screenshot from 2016-06-07 22:10:27.png
錯誤提示找不到pcre.h這個標頭檔案,解決方法是安裝一個依賴庫

Screenshot from 2016-06-07 22:13:57.png

[2]
Screenshot from 2016-06-07 22:15:20.png
在網上查了一下是少了連結庫libpcre.la

解決方案:

mkdir -p /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs
cp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.a
cp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.la
cp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.a
cp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.la
但是我發現/usr/lib(系統共享庫)下面沒有libpcre.a,其實我還沒有執行過pcre和openssl的編譯,這是致命的啊!!!
>編譯openssl
 cd  /home/wangxiong/Soft/nginx_station/openssl-1.0.1t
 ./config
 ./config -t
 make depend 
 make
 make test
 make install

>編譯pcre
./configure 
make
make install
預設共享庫安裝在/usr/local/下面
然後開始執行上面的拷貝命令
cp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.a
cp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.la
cp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.a
cp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.la

連結庫有了,然後再次make編譯

Screenshot from 2016-06-08 10:55:01.png

新的問題又來了,少了一堆變數,什麼鬼
網上查了一下,發現pcre其實有2種庫

Screenshot from 2016-06-08 11:49:05.png

心裡一萬個草泥馬有沒有,重新下載PCRE庫

Screenshot from 2016-06-08 11:48:40.png

解壓pcre,配置,編譯,很順利

 ./configure --prefix=/home/wangxiong/Soft/nginx_station/pcre-8.37
make
make install

接著重新配置編譯nginx

sudo ./configure --prefix=/usr/local/nginx --with-pcre=/home/wangxiong/Soft/nginx_station/pcre-8.37 --with-zlib=/home/wangxiong/Soft/nginx_station/zlib-1.2.8 --with-openssl=/home/wangxiong/Soft/nginx_station/openssl-1.0.1t  --with-http_ssl_module
make -j4
make install

make成功後

Screenshot from 2016-06-08 12:01:37.png

make install 成功後

Screenshot from 2016-06-08 12:01:37.png

檢視nginx安裝目錄

Screenshot from 2016-06-08 12:07:52.png
加許可權啟動nginx伺服器

sudo ./nginx

用瀏覽器訪問,看是否已經啟動

Screenshot from 2016-06-08 12:12:02.png

退出伺服器

sudo ./nginx -s stop

相關推薦

直播nginx伺服器搭建

nginx依賴pcre和zlib和openssl,分別去這兩個官方網站下載最新的版本. pcre下載頁面> zlib下載頁面> openssl下載頁面> 最後統一拷貝到某個目錄下 用命令解壓3個檔案

iOS直播--Nginx伺服器搭建和RTMP,HLS實現

Nginx介紹Nginx ("engine x") 是一個高效能的HTTP和反向代理伺服器,也是一個IMAP/POP3/SMTP伺服器。Nginx是由Igor Sysoev為俄羅斯訪問量第二的Rambler.ru站點開發的,第一個公開版本0.1.0釋出於2004年10月

ubuntu下使用nginxnginx-rtmp-module配置直播伺服器

本來準備在centos伺服器上搭建的,因為筆者工作系統是ubuntu,因此直接在本機上搭建,更方便快捷,配置過程比較簡單,記錄一下。 目錄 配置環境 安裝obs-studio開始第一次推流 安裝vlc播放器開始拉流 配置環境 配置環境 配

FFmpeg+Nginx搭建RTMP直播服務

    Nginx是優秀的開源並且可以新增外掛的服務端,其中就有開源的RTMP外掛nginx-rtmp-module實現了RTMP推流服務。     專案地址為: https://github.com/arut/nginx-rtmp-module 搭建思路:    

Mac平臺直播搭建

Homebrew Homebrew ( ['hoʊmbru:] ), 簡稱brew,是Mac OSX上的軟體包管理工具,能在Mac中方便的安裝軟體或者解除安裝軟體,類似於Linux系統中的apt-get, yum.  Homebrew的安裝: ruby -e "$(curl -fsSL https:

nginx-rtmp-module授權機制實現直播多房間授權認證

假設nginx直播伺服器已經搭建完畢,如果還沒有搭建完畢可以查閱利用nginx的nginx-rtmp-module搭建流媒體直播伺服器這篇文章。在開發直播專案時推流應該是需要做許可權認證的,不是任何人都可以隨意向直播伺服器推流,這就需要許可權認證,實現起來也不復雜,只需要在nginx配置檔案中的rt

直播nginx-rtmp-module整合

戰鬥民族俄羅斯人民開發的一款NGINX的流媒體外掛,除了直播發布音視訊流之外具備流媒體伺服器的常見功能 比如推拉流媒體資源 基於HTTP的FLV/MP4 VOD點播 HLS (HTTP Live Streaming) M3U8的支援 基於http的操

day122:MoFang:OSSRS媒體直播伺服器&基於APICloud的acLive直播模組實現RTMP直播

目錄 1.docker安裝OSSRS流媒體直播伺服器 2.基於APICloud的acLive直播推流模組實現RTMP直播推流 3.直播流管理 1.docker安裝OSSRS流媒體直播伺服器 1.OSSRS簡介 在外界開發中, 如果要實現直播功能.常用的方式有: 1. 通過第三方介面來實現. 可以申請阿里雲

寫代碼實現直播

global tag double 掌握 點播 -i void turn duration 花滿樓原創 小白:你之前介紹過使用nginx來實現直播,使用攝像頭來錄制,這些知識已經可以做到推流了。 花滿樓:之前是使用ffmpeg命令來推流,控制度不夠高,現在以代碼的方式

直播方案及過程分解

直播過程 1.相機預覽及資料採集Camera — 取資料(onPreviewFrame(Byte[] rawFrameData, Camera camera)) 2.原始幀處理(Rotate旋轉/Scale縮放:使用Libyuv/FFmpeg等工具庫) 3.編碼器編碼得到相應的h

[轉]不用任何第三方,寫一個RTMP直播

2016年是移動直播爆發年,不到半年的時間內無數移動直播App掀起了全民直播的熱潮。然而個人覺得直播的門檻相對較高,從推流端到服務端器到播放端,無不需要專業的技術來支撐,僅僅推流端就有不少需要學習的知識。目前大部分直播採用的都是RTMP協議,我這裡寫一個簡單的Demo,幫助大家更好的理解直播推流的過

android平臺下基於ffmpeg採集Camera資料編碼成H.264到RTMP伺服器

音視訊實踐學習 android全平臺編譯ffmpeg以及x264與fdk-aac實踐 ubuntu下使用nginx和nginx-rtmp-module配置直播推流伺服器 android全平臺編譯ffmpeg合併為單個庫實踐 android-studio使用c

阿里直播SDK,直播地址和播地址生成

最近,公司要搞螢幕遠端控制,包含了螢幕直播。一開始公司準備自己搭伺服器的,後來 公司java後臺說伺服器轉碼,前端還要外掛的,麻煩之類的。然後就變成了用阿里的SDK 一條龍服務。 不過 我自己在前期調研階段 ,也自己實現了直播推送H.264 到伺服器,伺服器轉發

直播實現RTMP協議的一些注意事項

018年8月4日第三次更新,詳細介紹了RTMP協議與遇到的坑,另外純Java重寫了RTMP協議,做了個Android 推流專案,包含安卓相機採集,編碼和RTMP推流,上傳到github了。 專案地址:https://github.com/gezhaoyou/SimpleLivePublisherLi

直播過程詳細分析

直播過程1.相機預覽及資料採集Camera — 取資料(onPreviewFrame(Byte[] rawFrameData, Camera camera)) 2.原始幀處理(Rotate旋轉/Scale縮放:使用Libyuv/FFmpeg等工具庫) 3.編碼器編碼得到相應的

Android視訊直播的實現(包括伺服器搭建

http://blog.csdn.net/huaxun66/article/details/53427771 最近一段時間,視訊直播可謂大火。在視訊直播領域,有不同的商家提供各種的商業解決方案,包括軟硬體裝置,攝像機,編碼器,流媒體伺服器等。本文要講解的是如

視訊直播與拉的實現

序言 最近在研究直播的彈幕,東西有點多,準備記錄一下免得自​​己忘了又要重新研究,也幫助有這方面需要的同學少走點彎路。關於直播的技術細節其實就是兩個方面一個是推流一個是拉流,而彈幕的實現核心在即時聊天,使用聊天室的就能實現,只是訊息的展示方式不同而已。在大多數的

大資料視覺化Nginx伺服器日誌分析及視覺化展示(Nginx+flume+HDFS+Spark+Highcharts)

專案說明: 本專案為一個web程式,能夠利用大資料技術,對nginx伺服器的訪問日誌進行圖形化展示。當訪問此程式時,可以看到nginx日誌中統計出來的全天分時網站點選量等資訊的圖表展示。每條Nginx日誌的平均大小為250位元組左右,假設每天產生1億條訪問日誌

騰訊直播——SDK(Android)

功能篇 騰訊視訊雲RTMP SDK由兩部分構成:推流器 + 播放器,本文將主要介紹推流器的相關資訊。 該SDK遵循標準RTMP視訊推送協議,可以對接包括騰訊雲在內的標準視訊直播伺服器。與此同時,SDK內部囊括了騰訊音視訊團隊多年的技術積累,在視訊壓縮、硬體加速、美顏濾鏡、音訊降噪、位元速率控制等方面都

音視訊採集封裝到直播原理

上次好早之前也寫過一篇,隨著工作的深入對這塊知識又鞏固了一遍,算是一個重寫和擴充套件版 舊的總結跳轉,那麼有啥不同呢? 1. 介紹協議的優缺點以及怎麼選擇 2. 會介紹壓縮編碼的原理 3. 測試關注的質量指標 那麼基本框架其實是