wids服务器php-cgi,window + nginx-rtmp + php-cgi 服务器搭建

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

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;

include other.conf;

}

当前目录创建 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.参考文献

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值