直播推流之nginx服务器搭建

nginx依赖pcre和zlib和openssl,分别去这两个官方网站下载最新的版本.
pcre下载页面>

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 21:14:40.png

zlib下载页面>

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 21:12:32.png

openssl下载页面>

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 21:11:17.png

最后统一拷贝到某个目录下

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 21:18:22.png

用命令解压3个文件
tar -xzvf xxx.tar.gz
tar -jxvf xxx.tar.bz2

到官网下载nginx>

《直播推流之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]

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 22:10:27.png

错误提示找不到pcre.h这个头文件,解决方法是安装一个依赖库

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-07 22:13:57.png

[2]

《直播推流之nginx服务器搭建》 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编译

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 10:55:01.png

新的问题又来了,少了一堆变量,什么鬼
网上查了一下,发现pcre其实有2种库

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 11:49:05.png

心里一万个草泥马有没有,重新下载PCRE库

《直播推流之nginx服务器搭建》 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成功后

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 12:01:37.png

make install 成功后

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 12:01:37.png

查看nginx安装目录

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 12:07:52.png

加权限启动nginx服务器

sudo ./nginx

用浏览器访问,看是否已经启动

《直播推流之nginx服务器搭建》 Screenshot from 2016-06-08 12:12:02.png

退出服务器

sudo ./nginx -s stop

    原文作者:shone
    原文地址: https://www.jianshu.com/p/d28c51360210
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞