直播推流之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解压出来的目录

wangxiong@Dell:~/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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,133评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,682评论 3 390
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,784评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,508评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,603评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,607评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,604评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,359评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,805评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,121评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,280评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,959评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,588评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,206评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,442评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,193评论 2 367
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,144评论 2 352

推荐阅读更多精彩内容