温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么进行window + nginx-rtmp + php-cgi 服务器搭建

发布时间:2021-10-18 16:03:41 来源:亿速云 阅读:115 作者:柒染 栏目:服务器

这篇文章将为大家详细讲解有关怎么进行window + nginx-rtmp + php-cgi 服务器搭建,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

1、首先需要准备的应用程序包。

nginx : nginx-rtmp-win32 或 nginx/Windows-1.0.4 (无rtmp模块)

php:php-5.2.16-nts-Win32-VC6-x86.zip  (nginx下php是以FastCGI的方式运行,所以我们下载非线程安全也就是nts的php包)

RunHiddenConsole: RunHiddenConsole.zip(用于cmd 非阻塞运行进程)

2、安装与配置。

1)php的安装与配置。

直接解压下载好的php包,到D盘wnmp目录(D:wnmp),这里把解压出来的文件夹重命名成php5。进入文件夹修改php.ini-recommended文件为php.ini,并用Editplus或者Notepad++打开来。找到

扩展目录(去掉注释)

;extension_dir = "ext"

mysql 扩展(去掉注释)

;extension=php_mysql.dll ;extension=php_mysqli.dll

前面指定了php的ext路径后,只要把需要的扩展包前面所对应的“;”去掉,就可以了。这里打开php_mysql.dll和php_mysqli.dll,让php支持mysql。当然不要忘掉很重要的一步就是,把php5目录下的libmysql.dll文件复制到C:Windows目录下,也可以在系统变量里面指定路径,当然这里我选择了更为方便的方法^_^。

到这里,php已经可以支持mysql了。

接下来我们来配置php,让php能够与nginx结合。找到(去掉注释)

;cgi.fix_pathinfo=1

这一步非常重要,这里是php的CGI的设置。

2)nginx的安装与配置。

把下载好的nginx-1.0.4的包同样解压到D盘的wnmp目录下,并重命名为nginx。接下来,我们来配置nginx,让它能够和php协同工作。进入nginx的conf目录,打开nginx的配置文件nginx.conf,找到

worker_processes  1;  error_log  logs/error.log debug;  events {     worker_connections  1024; }  rtmp {     server {         listen 1936;          application live {             live on;             pull rtmp://live.hkstv.hk.lxdns.com/live/hks live=1 name=1;         }     } }  http {          access_log logs/access.http.log;     server_tokens off;     default_type application/octet-stream;     client_max_body_size 10G;     sendfile on;

当前目录创建 other.conf

server {         listen      7777;         server_name live_stream;         root www;                  index index.php;          location / {             if (!-e $request_filename) {                 rewrite ^(.*)$ /index.php?s=/$1 last; # rewrite mode                 #rewrite ^(.*)$ /index.php/$1 last; # pathinfo mode             }         }                  location ~ \.php$ {                         fastcgi_hide_header X-Powered-By;             fastcgi_pass 127.0.0.1:9000;             fastcgi_split_path_info ^(.+\.php)(.*)$;             fastcgi_param PATH_INFO $fastcgi_path_info;             fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;             include fastcgi_params;             fastcgi_connect_timeout 300;             fastcgi_send_timeout 300;             fastcgi_read_timeout 300;          }     }

保存配置文件,就可以了。

nginx+php的环境就初步配置好了,来跑跑看。我们可以输入命令

X:\wnp\php\php-cgi.exe -b 127.0.0.1:900 -c X:\wnp\php\php.ini

双击nginx.exe

完成!!!

3.批处理脚本控制开关服务器

1.start.cmd

@echo off REM Windows 下无效 REM set PHP_FCGI_CHILDREN=5  REM 每个进程处理的***请求数,或设置为 Windows 环境变量 set PHP_FCGI_MAX_REQUESTS=1000   echo Starting PHP FastCGI... RunHiddenConsole D:/wnmp/php5/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini   echo Starting nginx... RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx

2.end.cmd

@echo off echo Stopping nginx...   taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul exit

4.填坑

php 文件无法接收参数,$_GET,$_POST,$_REQUEST,为空

解决办法:other.conf 文件中, “include fast_params” nginx官网示例

location ~ \.php$ {                             fastcgi_hide_header X-Powered-By;                 fastcgi_pass 127.0.0.1:9000;                 fastcgi_split_path_info ^(.+\.php)(.*)$;                 fastcgi_param PATH_INFO $fastcgi_path_info;                 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                                  include fastcgi_params;                                   fastcgi_connect_timeout 300;                 fastcgi_send_timeout 300;                 fastcgi_read_timeout 300;                  }

5.参考文献

1.windows下配置nginx+php环境

关于怎么进行window + nginx-rtmp + php-cgi 服务器搭建就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI