配置nginx播放视频

我们进入usr目录创建nginx文件夹

首先下载nginx安装包

wget http://nginx.org/download/nginx-1.6.3.tar.gz

后下载nginx_rtmp_module安装包

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

解压就完事了

tar xf nginx-1.6.3.tar.gz

unzip master.zip

如果提示

-bash: unzip: 未找到命令

yum install -y unzip zip

创建软链接

ln -s /usr/nginx/nginx-1.6.3 /usr/nginx/nginx

后配置nginx

cd nginx

使用

echo $?

如果输出0代表没有问题,但是此时输出1

以下是一些特殊变量:
$# 表示参数个数。
$0 是脚本本身的名字。
$1 是传递给该shell脚本的第一个参数。
$2 是传递给该shell脚本的第二个参数。
$@ 表示所有参数,并且所有参数都是独立的。
$$ 是脚本运行的当前进程ID号。
$? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误。

安装

yum -y install pcre-devel

yum -y install openssl openssl-devel

后再执行一次,注意!!!!!这里是两个点,点点/,编辑器显示三个点!!!!!

./configure --with-http_ssl_module --add-module=…/nginx-rtmp-module-master

如果报
./configure: error: C compiler cc is not found

yum -y install gcc gcc-c++ autoconf automake make

再次执行那个

./configure --with-http_ssl_module --add-module=…/nginx-rtmp-module-master

然后好了,尾巴变成

adding module in ../nginx-rtmp-module-master
 + ngx_rtmp_module was configured
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  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"

echo $?

发现是0

编译nginx,后确认有无成功

make

echo $?

安装nginx,自己确认

make install

启动nginx

/usr/local/nginx/sbin/nginx

查看nginx版本

/usr/local/nginx/sbin/nginx -V

查看配置文件,可以看到他在监听80端口诶,我们关闭防火墙,访问ip地址:80可以看到欢迎来到nginx的页面

cat /usr/local/nginx/conf/nginx.conf

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

语法检查,ok+success呢

/usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

拉个视频进去

cd /usr/local/nginx/html/

(平滑重启nginx???没啥用好像 …/sbin/nginx -s reload)

访问http://192.168.1.100/B961041_20191126155620000_00003.mp4

当我们reboot后发现,nginx不再启动,所以我们配置自动重启

vi /etc/rc.local

增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:

cd /etc

chmod 755 rc.local

当然咯,我们可以改变ip地址,把80改成which ever you want
也可以改nginx路径,先关闭nginx,把

location / {
root html;
index index.html index.htm;
}
里面的htlm改成绝对路径,如/data/download;这种,然后./nginx启动

小贴士

1.启动、停止nginx

cd /usr/local/nginx/sbin/

./nginx

./nginx -s stop

./nginx -s quit

./nginx -s reload重新加载配置文件(不需要重启)

./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。

2.重启 nginx

先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:

./nginx -s quit
./nginx

3.重新加载配置文件:

当 nginx的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload 不用先停止 nginx再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload

即可启动成功

4.nginx在哪

whereis nginx

nginx: /usr/local/nginx
引用:

https://zhidao.baidu.com/question/436695753.html

https://blog.csdn.net/fukai8350/article/details/80634566

https://blog.csdn.net/weixin_34021089/article/details/91622151

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值