windows下配置NGINX+PHP+MYSQL (No input file specified 问题)


先说下来自个人遇到的问题,这部分不是转的:

按照下列教程配置完毕后遇到一个问题  No input file specified. 解决方法 : 若在配置文件中没有用到过

$document_root 这个参数 那么直接写你自己的工作目录在上面否则报错,看如下我个人的例子


 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           D:/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  D:/www/$fastcgi_script_name;
            include        fastcgi_params;
        }

转自: http://www.myxzy.com/post-352.html


相对于linux来说,windows配置web环境不管是一键安装包还是独立配置简单多了,这次是讲以NGINX作为web的本地的测试环境。

现在越来越多的网站使用以NGINX作为web服务器的环境了。想在windows xp模下安装NGINX作为本地测试环境,但是用一键安装包很多多是老的稳定的版本,所以想独立的配置NGINX-1.3.8、PHP-5.4.8 和 MYSQL-5.5.8的本地环境用作测试。主要讲把环境配置起来,像mysql安装什么过程我这里就略过了。


第一部分:准备工作。(windows xp sp3)

1.首先是下载软件。

NGINX-1.3.8官网下载:http://nginx.org/en/download.html

PHP5.4.8版本下载地址:http://windows.php.net/download/

Mysql5.5.28版本下载地址:http://www.mysql.com/downloads/mysql/

2.安装mysql软件。


3.解压NGINX和PHP到你自己安装位置。这里我多装在D盘。

NGINX目录D:\nginx

PHP目录D:\php


第二部分:安装nginx

1.打开D:\nginx目录,运行该文件夹下的nginx.exe

2.测试是否启动nginx。打开浏览器访问http://localhost 或 http://127.0.0.1,看看是否出现“Welcome to nginx!”,出现的证明已经启动成功了。没有启动的话,看看80端口有占用没。

注意:该网站目录在D:\nginx\html下

点击查看原图


第三部分:安装php(这里主要讲nginx配置启动php,以cgi运行php)

nginx配置文件是conf文件夹里的nginx.conf

1.修改大概第43~45行之间的


        location / {
            root   html;
            index  index.html index.htm;
        }

修改网站文件的路径,以及添加index.php的默认页。


        location / {
            root   D:/www;
            index  index.html index.htm index.php;
        }
2.支持php的设置


修改大概在第63-71行的


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

先将前面的“#”去掉,同样将root  html;改为root   D:/www;。再把“/scripts”改为“$document_root”,这里的“$document_root”就是指前面“root”所指的站点路径,这是改完后的:

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           D:/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }


3.D:/php下复制php.ini-development文件,并将文件名改为php.ini,修改php配置文件php.ini,保存即可。

第730行 ; extension_dir = "ext" 先去前面的分号再改为 extension_dir = "D:\php\ext"

第919行 ;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai

第736行enable_dl = Off 改为 enable_dl = On

第743行 ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

第771行 ;fastcgi.impersonate = 1 去掉前面的分号

第783行 ;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1


第880、881行,去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll   (支持MYSQL数据库)


其他的配置请按照自己的需求更改。


第三部分试运行以及编辑运行配置文件

D:\php>php-cgi.exe -b 127.0.0.1:9000 -c D:\php\php.ini
任务管理器先结束 nginx.exe,在重新运行nginx.exe。


D:/www下新建一个index.php,

<?php phpinfo(); ?>

访问出现php的信息就说明php已经成功安装。


下载一个RunHiddenConsole.exe,百度网盘

开启php-cgi和nginx.exe,保存为start.bat


@echo off
echo Starting PHP FastCGI...
D:\nginx\RunHiddenConsole.exe D:\PHP\php-cgi.exe -b 127.0.0.1:9000 -c D:\PHP\php.ini
echo Starting nginx...
D:\nginx\RunHiddenConsole.exe D:/nginx/nginx.exe -p D:/nginx



停止php-cgi和nginx.exe,保存为stop.bat

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

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值