centos7搭建流媒体服务器
首先进入local目录
cd /usr/local
下载nginx(没有安装wget的请安装,安装命令:yum -y install wget)
wget http://nginx.org/download/nginx-1.9.9.tar.gz
解压
tar zxvf nginx-1.9.9.tar.gz
mv nginx-1.9.9 nginx
创建nginx安装目录与模块目录
mkdir -p /usr/local/nginx/module
创建视频数据存放位置
mkdir -p /usr/local/nginx/myapp
进入到/usr/local/nginx/module目录
cd /usr/local/nginx/module
下载nginx-rtmp-module,下载后的文件夹名叫nginx-rtmp-module
git clone https://github.com/arut/nginx-rtmp-module.git
// 会出现Git error
git error: RPC failed; result=35, HTTP code = 0 fatal: The remote end hung up unexpectedly
解决:通过设置Git的http缓存大小,解决了这个问题,在当前工程目录下运行如下命令:
git config --global http.postBuffer 20M
如果20M不行就 50M
进入解压后的nginx目录中,指定nginx安装目录并且指定了安装的模块
cd /usr/local/nginx/
./configure --prefix=/usr/local/nginx --add-module=/usr/local/nginx/module/nginx-rtmp-module --conf-path=/usr/local/nginx/nginx.conf
错误提示:./configure报-bash: ./configure: No such file or directory
查找:find -name configure
进入目录执行
编译并安装
make && make install
错误为:./configure: error: the HTTP rewrite module requires the PCRE library
安装pcre-devel解决问题
yum -y install pcre-devel
还有可能出现:
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决办法:
yum -y install openssl openssl-devel
启动nginx
/usr/local/nginx/sbin/nginx &
此时如果没有问题,那么你就可以访问linux地址http://192.168.1.79/了,会出现welcome界面。
启动代码格式:nginx安装目录地址 -c nginx配置文件地址
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
查看nginx进程
ps -ef | grep nginx
重新加载配置文件
/usr/nginx/sbin/nginx -s reload
打印配置文件是否正确
/usr/nginx/sbin/nginx -t
查找nginx位置
whereis nginx