windows下配置Nginx支持php

编辑配置文件nginx.conf

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 7000;
server_name localhost;
location / {
root C:/nginx/HTMS3.0/htms3.0/public;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
root C:/nginx/HTMS3.0/htms3.0/public;
fastcgi_pass 127.0.0.1:9010;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 7010;
server_name localhost;
location / {
root C:/nginx/HTMS3.0/htms_api/public;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
root C:/nginx/HTMS3.0/htms_api/public;
fastcgi_pass 127.0.0.1:9010;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

}

开启脚本

start_nginx.bat

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

echo Starting PHP php...
C:\nginx\RunHiddenConsole.exe C:/php/php.exe -S 127.0.0.1:8000 -t C:\nginx\html\index

启动脚本

restart_nginx.bat

taskkill /F /IM nginx.exe > nul
taskkill /F /IM php-cgi.exe > nul
@echo off
echo Starting nginx...
C:\nginx\RunHiddenConsole.exe C:\nginx\nginx.exe -p C:\nginx
echo Starting PHP FastCGI...
C:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9010 -c C:\php\php.ini
C:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9011 -c C:\php\php.ini

 

no input file specified 解决方法

虚拟机测试nginx 遭遇 Noinput file specified,多方查找终于找到解决办法
 
1、 php.ini(/etc/php5/cgi/php.ini)的配置中这两项
 
cgi.fix_pathinfo=1 (这个是自己添加的)
 
doc_root=
 
2、nginx配置文件/etc/nginx/sites-available/default中注意以下部分
 
location ~ .php$ {
 
fastcgi_pass 127.0.0.1:9000;
 
fastcgi_index index.php;
 
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
 
include fastcgi_params;
 
}
 
上面的部分路径需要根据你主机主目录的实际情况填写
 
配置完以上部分,重启一下service nginx restart,应该没问题了

  

 

posted @ 2017-03-07 21:10  佚小名  阅读(334)  评论(0编辑  收藏  举报