首页 > 编程知识 正文

搭建本地局域网视频服务器,nginx配置web服务器

时间:2023-05-04 17:45:29 阅读:166262 作者:4904

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 2esac

nginx="/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文件。

rtmp { server { listen 1935; #server_name localhost; application liveApp { live on; } application vod { play /home/admin/ftp/video;//你的视频存放的位置 } application vod_http { play http://119.23.234.4/vod; } application hls { live on; hls on; hls_path /home/admin/ftp/software/nginx/objs/addon/hls;#注意为你的实际目录,可以通过find / -name hls查找。 } }} location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /usr/local/nginx/nginx-rtmp-module/;#注意,确保你的nginx下有这个文件,没有的话,可以把你解压后的文件复制粘贴过来。这里填你的原来的目录报错。 } location /hsl { types { application /vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /usr/local/nginx/nginx-rtmp-module/hls;//复制粘贴过来之后的hls目录。 add_header Cache-Control no-cache; } #location /dash { #root /tmp; #add_header Cache-Control no-cache; #}

合理安装之后,/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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。