直播推流之nginx服务器搭建

来源:互联网 发布:办户外婚礼多少钱知乎 编辑:程序博客网 时间:2024/05/16 10:19

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_modulechecking for OS + Linux 3.16.0-71-generic x86_64checking 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 ... foundchecking for -Wl,-E switch ... foundchecking for gcc builtin atomic operations ... foundchecking for C99 variadic macros ... foundchecking for gcc variadic macros ... foundchecking for gcc builtin 64 bit byteswap ... foundchecking for unistd.h ... foundchecking for inttypes.h ... foundchecking for limits.h ... foundchecking for sys/filio.h ... not foundchecking for sys/param.h ... foundchecking for sys/mount.h ... foundchecking for sys/statvfs.h ... foundchecking for crypt.h ... foundchecking for Linux specific featureschecking for epoll ... foundchecking for EPOLLRDHUP ... foundchecking for O_PATH ... foundchecking for sendfile() ... foundchecking for sendfile64() ... foundchecking for sys/prctl.h ... foundchecking for prctl(PR_SET_DUMPABLE) ... foundchecking for sched_setaffinity() ... foundchecking for crypt_r() ... foundchecking for sys/vfs.h ... foundchecking for nobody group ... not foundchecking for nogroup group ... foundchecking for poll() ... foundchecking for /dev/poll ... not foundchecking for kqueue ... not foundchecking for crypt() ... not foundchecking for crypt() in libcrypt ... foundchecking for F_READAHEAD ... not foundchecking for posix_fadvise() ... foundchecking for O_DIRECT ... foundchecking for F_NOCACHE ... not foundchecking for directio() ... not foundchecking for statfs() ... foundchecking for statvfs() ... foundchecking for dlopen() ... not foundchecking for dlopen() in libdl ... foundchecking for sched_yield() ... foundchecking for SO_SETFIB ... not foundchecking for SO_REUSEPORT ... foundchecking for SO_ACCEPTFILTER ... not foundchecking for IP_RECVDSTADDR ... not foundchecking for IP_PKTINFO ... foundchecking for IPV6_RECVPKTINFO ... foundchecking for TCP_DEFER_ACCEPT ... foundchecking for TCP_KEEPIDLE ... foundchecking for TCP_FASTOPEN ... foundchecking for TCP_INFO ... foundchecking for accept4() ... foundchecking for eventfd() ... foundchecking for int size ... 4 byteschecking for long size ... 8 byteschecking for long long size ... 8 byteschecking for void * size ... 8 byteschecking for uint32_t ... foundchecking for uint64_t ... foundchecking for sig_atomic_t ... foundchecking for sig_atomic_t size ... 4 byteschecking for socklen_t ... foundchecking for in_addr_t ... foundchecking for in_port_t ... foundchecking for rlim_t ... foundchecking for uintptr_t ... uintptr_t foundchecking for system byte ordering ... little endianchecking for size_t size ... 8 byteschecking for off_t size ... 8 byteschecking for time_t size ... 8 byteschecking for setproctitle() ... not foundchecking for pread() ... foundchecking for pwrite() ... foundchecking for pwritev() ... foundchecking for sys_nerr ... foundchecking for localtime_r() ... foundchecking for posix_memalign() ... foundchecking for memalign() ... foundchecking for mmap(MAP_ANON|MAP_SHARED) ... foundchecking for mmap("/dev/zero", MAP_SHARED) ... foundchecking for System V shared memory ... foundchecking for POSIX semaphores ... not foundchecking for POSIX semaphores in libpthread ... foundchecking for struct msghdr.msg_control ... foundchecking for ioctl(FIONBIO) ... foundchecking for struct tm.tm_gmtoff ... foundchecking for struct dirent.d_namlen ... not foundchecking for struct dirent.d_type ... foundchecking for sysconf(_SC_NPROCESSORS_ONLN) ... foundchecking for openat(), fstatat() ... foundchecking for getaddrinfo() ... foundcreating objs/MakefileConfiguration 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/.libscp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.acp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.lacp /usr/lib/libpcre.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.acp /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 makemake install默认共享库安装在/usr/local/下面然后开始执行上面的拷贝命令cp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.acp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/libpcre.lacp /usr/local/lib/libpcre2-8.a /home/wangxiong/Soft/nginx_station/pcre2-10.20/.libs/libpcre.acp /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.37makemake 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_modulemake -j4make 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

0 0
原创粉丝点击