php-fpm iswindows,windows本地配置php(yii)+nginx+fastcgi

一. 配置nginx支持php

官网下载nginx。

nginx.conf配置做如下更改:

# yii框架

server {

charset utf-8;

client_max_body_size 128M;

listen80; ## listen foripv4

#listen [::]:80 default_server ipv6only=on; ## listen foripv6

server_name www.yii.com;

root G:/demo/yii/basic/web;

index index.php;

access_log G:/demo/yii/basic/log/access.log;

error_log G:/demo/yii/basic/log/error.log debug;

location/{

# Redirect everything that isn't a real file to index.php

try_files $uri $uri/ /index.php$is_args$args;

}

# uncomment to avoid processing of calls to non-existing static files by Yii

#location ~ .(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {

# try_files $uri =404;

#}

#error_page 404 /404.html;

# deny accessing php files for the /assets directory

location ~ ^/assets/.*.php$ {

deny all;

}

location ~ .php$ {

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_pass 127.0.0.1:9000;

#fastcgi_pass unix:/var/run/php5-fpm.sock;

try_files $uri =404;

}

location ~* /. {

deny all;

}

}

配置好后重启nginx

(注意,这里配置了server_name为www.yii.com。需要同时配置host文件,把www.yii.com映射到127.0.0.1)

二. php安装yii

下载php包 配置环境变量

安装好后,启动yii服务测试是否正常:

php yii serve

4e81835553a49771e79607a194dfa2e9.png

修改php.ini支持fastCGI:

搜索“extension_dir”,找到: e;xtension_dir = "ext" 先去前面的分号再改为 extension_dir = "D:phpext"

搜索“date.timezone”,找到:;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai

搜索“enable_dl”,找到:enable_dl = Off 改为 enable_dl = On

搜索“cgi.force_redirect” ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

搜索“fastcgi.impersonate”,找到: ;fastcgi.impersonate = 1 去掉前面的分号

搜索“cgi.rfc2616_headers”,找到:;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1

搜索“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll  去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll   (支持MYSQL数据库)

三. 启动fastCGI服务

什么是fastCGI?它有什么用?可以参考另一篇文章:php中fastcgi和php-fpm是什么东西

打开cmd命令:

C:UsersAdministrator>D:/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/php/php.ini

67e3cb61bc24a158dae73a757378eff8.png

启动后,看似没反应,实际已在任务管理器增加了php-cgi进程:

d1f71cadd98cddd76c8b6dde4b5049c4.png

保持cmd命令行不退出,访问www.yii.com,发现可以正常访问:

a3ad6880ac0cd5116c9a3c60bc2f12c1.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值