使用ngixn最最最重要的事:看报错的日志文档!
!!
alias出现404,首先仔细核对alias后面的路径是否正确!
!!
以下为Windows下的操作,且为避免权限问题,以管理员身份启动Nginx
Liinux下别用管理员身份启动
一 安装
报错原因: https://blog.csdn.net/bugknightyyp/article/details/21088035
报错解决【照着做未成功】:https://www.cnblogs.com/shangjun6/p/11805054.html
windows下nginx不要想加入环境变量。
Nginx启动时,如果没有指定配置文件,则在当前路径下找配置文件。
启动cmd时,当前路径为C:/User/XXX。
可用Nginx -c指定配置文件,但是指定时,依然报上面那个错。
所以,要么把配置文件拷贝一份到C:/User/XXX中,要么老老实实到所在目录中启动。
二 启动与关闭
nginx操作命令:https://www.cnblogs.com/lxwphp/p/8309988.html
https://www.cnblogs.com/lxwphp/p/8309988.html
https://www.cnblogs.com/deepalley/p/11108634.html
不知为何,Nginx无法关闭,且无法在任务管理器中关闭,必须通过cmd命令关闭。
另外,Nginx会同时存在多个进程。
查看所有nginx进程:详见上述教程
tasklist /fi "imagename eq nginx.exe"
关闭方法:详见上述教程
taskkill /f /t /im nginx.exe
三 具体问题
3.1 Nginx处理跨域:
https://segmentfault.com/a/1190000019227927?utm_source=tag-newest
使用flvjs时,即使是静态HTML,设置播放源依然存在跨域问题,需要Nginx解决跨域。
location /vod/ {
add_header 'Access-Control-Allow-Origin' '*'; # 添加额外的HTTP头
add_header 'Access-Control-Allow-Credentials' 'true'; # 添加额外的HTTP头
alias D:/nginx/save/vod/;
}
注意:对alias的理解,alias不是重定向,不是将url中的/vod/替换后重新请求,
可以理解为将http://.../vob/全部替换后在服务器中查找文件
3.2 Nginx-RMTP保存视频
Nginx-RMTP:
配置:手动控制录像开始和结束,即通过HTTP请求控制;
这样可以实现由前端控制录像开始和结束。
感到Linux比WIndows更适合开发的一个点:
Linux中路径格式更加一致,都是/连起来的,不像Windows有C:这种盘符符号。
Nginx配置中不要使用相对路径,都用绝对路径更好。
注意:windows文件名中不能包含冒号":",linux下可以;
3.3 Nginx处理时间格式:
Windows下可用的Nginx中时间格式:-%Y-%m-%d-%H_%M_%S.flv
https://blog.csdn.net/u011242657/article/details/79954269
很多博客中用的另一种时间格式,导致月份中出现汉字“月”,从而Nginx无法创建文件。
3.4 Nginx添加新的第三方模块:
【已编译,再新加模块】
https://www.jb51.net/article/137656.htm
https://blog.csdn.net/zxc_user/article/details/81879823
发布模块的作者都写了编译为动态模块,用 --add-dynamic-module代替–add-module,还没试过。
四 参考资料
Nginx配置文件解释:
https://www.cnblogs.com/yinfutao/p/10014364.html
Nginx使用:
https://www.jianshu.com/p/a43635f80618
Nginx-RTMP指令解释:
https://blog.csdn.net/defonds/article/details/9274479/
https://blog.csdn.net/weixin_30697239/article/details/95425488
https://www.cnblogs.com/lidabo/p/7601854.html
Nginx-RTMP实现保存:
https://bbs.csdn.net/topics/392284058
https://blog.csdn.net/u011242657/article/details/79954269
nginx-http-flv-module配置:
https://blog.csdn.net/winshining/category_6459580.html
https://blog.csdn.net/hjing123/article/details/103983309
https://blog.csdn.net/string_kai/article/details/100598268
nginx使用大全:
https://www.cnblogs.com/EdwinChan/p/8350984.html
https://blog.csdn.net/u012062760/category_5743051.html