Web直播系列1——nginx服务器在liunx和windows的搭建

前提:

电脑的系统为分别为64位Ubuntu16.04TLS和64位的Win7旗舰版

目的:

搭建可推流拉流的nginx服务器

Ubuntu下的安装方法:

1)安装目录为根目录下的/home/zz(用户名)目录

2)安装所需依赖

  • 安装openssl
wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
tar -zxvf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e/
./config
make & make install
  • 注意:openssl版本要和nginx匹配,不匹配的openssl会使nginx编译时出错。
  • 安装zlib
wget https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure
make & make install
  • 安装pcre
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40/
./configure
make & make install

3)下载nginx-rtmp-module(推拉rtmp流所需)

git clone https://github.com/arut/nginx-rtmp-module.git

4)安装nginx

  • 注意:安装编译nginx时,应该在root(sudo -i)用户下,否则在编译时会因权限不够无法生成/usr/local/nginx文件夹进而出错。
wegt http://nginx.org/download/nginx-1.13.6.tar.gz
tar -zxvf nginx-1.13.6.tar.gz
cd nginx-1.13.6
./configure --prefix=/usr/local/nginx  --add-module=../nginx-rtmp-module  --with-http_ssl_module  --with-pcre=/home/zz/pcre-8.40  --with-zlib=/home/zz/zlib-1.2.11  --with-openssl=/home/zz/openssl-1.1.0e
make & make install

5)测试

  • 启动nginx
cd /usr/local/sbin/nginx
./nginx
    • 出现端口已被占用
lsof -i:80 或者 ps -ef | grep nginx #查看占用80端口的进程
kill -9 xxx #关掉该进程
重新启动 
  • 浏览器输入电脑IP,出现Welcome to nginx 代表安装成功!!!

Windows下的安装方法:

注意:nginx建议在liunx系统下使用~

  • 下载nginx 
  • 注意:下载nginx版本最好为1.3以后的,否则on_play等功能不能使用
http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip
  • 下载nginx-rtmp-module-master
https://github.com/arut/nginx-rtmp-module/
  • 将nginx-rtmp-module-master解压后复制到nginx 1.7.11. Gryphon的解压目录下nginx(修改文件夹名字)
  • 测试(进入cmd)
cd nginx
nginx.exe -c conf\nginx-win.conf
  • 浏览器输入电脑IP,出现Welcome to nginx 代表安装成功!!!

参考:

https://blog.csdn.net/fireroll/article/details/51985688

https://blog.csdn.net/luyaran/article/details/53908846

https://www.linuxidc.com/Linux/2017-03/141825.htm

猜你喜欢

转载自blog.csdn.net/zzhang_12/article/details/79784320