Nginx与视频点播和视频直播服务器一起构建环境:
Centos 7,(推荐。 Ubuntu不容易使用。 会报告莫名其妙的错误。 )
Nginx1.10.1
二.系统环境构建
首先,我们不建议每个人安装这些软件。 由于这很耗时且容易出错,因此建议使用yum install ***命令进行安装。 错误的概率很低。
资源链接:链接: https://pan.Baidu.com/s/1 wmjypq _ b 089 OJ 783 FZ jx0g
抽屉代码: bk0v
1、首先说明默认安装过程
(1)、yum install gcc gcc-c
) 2、yum install openssl openssl-devel
(3)、yum insall pcre pcre-devel
) 4、yum install zlib zlib-devel
) 5、点,下载nginx-rtmp-module-master
命令: git clone https://github.com/arut/nginx-rtmp-module.git
解冻:
) 6、编译安装nginx
进入解压后的目录,然后进入./configure---prefix=/usr/local/nginx---add-module=/home/admin/FTP/software/nginx
注意:编译时可能会报告错误。 例如,如果找不到openssl,但输入openssll就会显示。 这是为什么呢,因为没有安装openssl-devel。
编译,注意:/home/admin/ftp/software/是解压缩您自己定义的rtmp包的目录。
2、否则,下载并解压缩压缩包,然后编译(./configure-- prefix=/usr/local/your name (-makemake install )。 错误率很高,所以请不要交易。
三.启动nginx
测试时,我们发现无论是在service nginx start还是systemctl start nginx上都无法正常工作,所以我们需要自己将nginx添加到服务中。 在/etc/init.d/中创建nginx文件。 (创建方法,vi nginx——:wq退出保存)。
特别注意(#! /安静的往事/sh一定要放在第一行,复制粘贴的时候不要忘记。
#! /宁静的往事/sh # nginx-thisscriptstartsandstopsthenginxdaemin # # chkconfig 3360-8515 # description 3360 nginxanhttp (s ) setp (# proxyandimap/pop3proxy server # processname : nginx # config :/usr/local/nginx/conf/nginx.conf # pidfile RC.d/init.d/functions # sourcenetworkingconfiguration./etc/syscon cion checkthatnetworkingisup.[ ' $ networking ' nginx ' Prog=$ (local/nginx/conf/nginx.conf ' lockfile=/var/lock/subsys/nginx start ) {-x $ nginx } | echo [ $ retval-eq0 ] touch $ lockfile return $ retval } stop ({ echo-n $ ' stopping $ Prog 3360 ' killproc $ Prog-qui ing ) stop start } reload () { configtest || return $? echo -n $'Reloading $prog: '
killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2esacnginx="/usr/local/nginx/s安静的往事/nginx"这里的文件目录为你自己的目录,得确认你s安静的往事目录下有nginx这个文件。
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"这个也同上,注意自己的目录。
lockfile=/var/lock/subsys/nginx这一行不是很重要,我也不是很理解,我的subsys下并没有nginx这个文件,但是整个运行时没有报错的。
四、systemctl start nginx
五、修改nginx.conf文件。
合理安装之后,/usr/local/nginx下应当是有rtmp模块文件的,没有也没关系,只要你编译nginx的时候,他没有报错,(没有报not found错误)。把nginx-rtmp-module复制粘贴过去即可。
六、演示:
https://blog.csdn.net/zhangbijun1230/article/details/82356611
https://blog.csdn.net/weixin_34261739/article/details/88917741
https://www.linuxidc.com/Linux/2018-10/154934.htm