查看nginx当前进程
ps -aux|grep nginx
ps -aux|grep nginx
centos 7.2 安装Nginx和nginx-rtmp-module搭建直播流媒体服务器
本机安装目录
/usr/share/
1、在当前目录下载同版本的Nginx
cd /usr/share/
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
2、更新下依赖相关包
yum -y install pcre*
3、下载nginx-rtmp-module
cd /usr/share/
git clone https://github.com/arut/nginx-rtmp-module.git
mv nginx-rtmp-module nginx-rtmp-module-1.1.10
4、进入nginx-1.12.2目录
cd /usr/share/nginx-1.12.2
5、编译模块
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module-1.1.10 --with-
http_ssl_module
make #验证
make install
6、启动Nginx
cd /usr/local/nginx
./sbin/nginx
7、配置conf
参考资料
github:《nginx-rtmp-module》https://github.com/arut/nginx-rtmp-module
复制一份副本
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
编辑配置
vi /usr/local/nginx/conf/nginx.conf
rm -rf /usr/local/nginx/conf/.nginx.conf.swp
在events {}下面添加以下代码
参考《Nginx.conf》
nginx.rar
rtmp_auto_push on; # Multi-Worker
rtmp {
server {
listen 1935;
chunk_size 4096; #//数据传输块的大小
allow play all;
application live {
live on; # 启用rtmp
#publish_notify on; # 启用notify
# on_publish http://127.0.0.1/notify/publish;
# on_play http://127.0.0.1:8080/rtmp/notify/play;
# on_play_done http://127.0.0.1:8080/rtmp/notify/play_done;
# on_publish_done http://127.0.0.1/notify/publish_done;
# on_record_done http://127.0.0.1:8080/rtmp/notify/record_done;
# on_update http://127.0.0.1:8080/rtmp/notify/update;
hls on; # 启用hls
wait_key on; #对视频切片进行保护,这样就不会产生马赛克了
hls_path /www/web/default/live; #切片视频文件存放位置
hls_fragment 10s; #每个视频切片的时长
hls_continuous on; #连续模式
hls_cleanup on; #对多余的切片进行删
# hls_plahls_nested on; #嵌套模式
record all;
record_path /www/web/default/vod; # 录制保存地址
#record_append on;
record_unique on;
#record keyframes;
#record_path /www/web/default/vod;
#record_max_frames 100;
#record_interval 20m;
#exec /usr/local/ffmpeg-3.4-64bit-static/ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name;
# 跟踪客户信息
exec_play bash -c "echo $addr $pageurl >> /tmp/clients";
exec_publish bash -c "echo $addr $flashver >> /tmp/publishers";
# 转换录制的文件格式的MP4
# exec_record_done /usr/local/ffmpeg-3wp:4-64bit-static/ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4;
}
# application live360p {
# live on;
# hls on; # 启用hls
# hls_path /home/live360p;
# record off;
# allow publish 127.0.0.1;
# deny publish all;
# }
}
}
在http{}前
8、nginx相关命令
/usr/local/nginx/sbin/nginx -s reload #重载配置
/usr/local/nginx/sbin/nginx -s stop #停止
/usr/local/nginx/sbin/nginx #开启
9、添加端口开放
firewall-cmd --query-port=1935/tcp
firewall-cmd --permanent --zone=public --add-port=1935/tcp
systemctl restart firewalld.service
10、设置开机启动
vi /lib/systemd/system/nginx.service
服务代码描述:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存后重载下服务
systemctl daemon-reload
命令详解:
systemctl enable nginx.service #启动服务
systemctl status nginx.service #查看服务状态
systemctl start nginx.service #开启服务
systemctl stop nginx.service #停止服务
systemctl restart nginx.service #重启服务
11、检查推流端口是否正常
cmd
telnet 140.143.157.56 1935

12、直播目录
live /www/web/default/live
vod /www/web/default/vod
13、推流地址
直播地址:rtmp://140.143.157.56/live/
串码:1111


用惯了windows的人,会习惯性地按Ctrl+S来保存,
当你在使用vi insert 保存应该用 命令模式--wq退出 而不是ctrl+s
估计你就是这么做的.
而该举动在vi中的结果就是将vi冻住
用Ctrl+Q可以解冻
1、添加Nginx存储库
sudo yum install epel-release
2、安装Nginx
sudo yum install nginx
3、启动Nginx
sudo systemctl start nginx
4、添加到防火墙
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
注意:firewall is not running
这里启动下防火墙
systemctl start firewalld
开放端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-port=23560/tcp
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=33481/tcp
5、安装成功后的Nginx地址
/usr/share/nginx/html/ 站点目录
/etc/nginx/conf.d/ 自定义Nginx站点配置文件存放目录
/etc/nginx/nginx.conf 全局配置
nginx -c nginx.confN ginx启动
6、查看nginx版本
nginx -V
查看到是:nginx/1.12.2
返回到Nginx的目录
cd /usr/share/
停止Nginx
systemctl stop nginx
启动Nginx
systemctl start nginx
卸载Nginx
yum remove nginx
笔记:
开启防火墙
systemctl start firewalld
关闭防火墙
systemctl stop firewalld
禁用防火墙服务
systemctl make firewalld
添加规则:
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-port=23560/tcp
firewall-cmd --permanent --add-port=8080/tcp
【旧防火墙机制】
安装iptables
yum -y install iptables-services
开启iptables
systemctl enable iptables
php.ini 中开启 fileinfo 扩展来获取正确的类型:
extension = php_fileinfo.dll
请检查!
最近小鱼哥要做个标签模糊查询的需求。
比如标签值:
tags:广州建站,番禺建站,企业建站
我想查询所有新闻Tags字段含有以上任意一个关键词的记录,怎么实现呢?
$tags =array("广州建站","番禺建站");
重组查询条件,因为模糊查询的like 关键词两边要追加“%”;
$map =array();
foreach($tags as $k=>$v){
$map[$k] ="%".$v."%";
}
$where['tags'] =array('like',$diff,'or');
以上得出的sql语句是
示例表为t_news 查询出6个记录 语法如下
**SELECT * FROM `t_news` WHERE (`tags` LIKE '广州建站' OR `tags` LIKE '番禺建站') ORDER BY update_time DESC LIMIT 6**
好了以上的查询就可以应用到thinkphp中去了。