Home  >  Article  >  Backend Development  >  nginx服务错误

nginx服务错误

WBOY
WBOYOriginal
2016-06-23 14:22:12923browse

运行PHP文件就报错。
配置文件如下

#user  nobody;worker_processes  2;error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '    #                  '$status $body_bytes_sent "$http_referer" '    #                  '"$http_user_agent" "$http_x_forwarded_for"';    #access_log  logs/access.log  main;    sendfile        on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;    #gzip  on;    server {        listen       80;        server_name  localhost;        #charset koi8-r;        #access_log  logs/host.access.log  main;        location / {            root   G:/wamp/www/ecshop;            index  index.html index.htm index.php;        }        error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }        # proxy the PHP scripts to Apache listening on 127.0.0.1:80        #        #location ~ \.php$ {        #    proxy_pass   http://127.0.0.1;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        location ~ \.php$ {            root           G:/wamp/www;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;	    fastcgi_param  SCRIPT_FILENAME G:/wamp/www/ecshop$fastcgi_script_name;	    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;	    #include fastcgi.conf;        }        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        #        #location ~ /\.ht {        #    deny  all;        #}    }    # another virtual host using mix of IP-, name-, and port-based configuration    #    #server {    #    listen       8000;    #    listen       somename:8080;    #    server_name  somename  alias  another.alias;    #    location / {    #        root   html;    #        index  index.html index.htm;    #    }    #}    # HTTPS server    #    #server {    #    listen       443;    #    server_name  localhost;    #    ssl                  on;    #    ssl_certificate      cert.pem;    #    ssl_certificate_key  cert.key;    #    ssl_session_timeout  5m;    #    ssl_protocols  SSLv2 SSLv3 TLSv1;    #    ssl_ciphers  HIGH:!aNULL:!MD5;    #    ssl_prefer_server_ciphers   on;    #    location / {    #        root   html;    #        index  index.html index.htm;    #    }    #}}

错误如下
2013/01/27 21:18:59 [error] 4592#4648: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"
求解答。


回复讨论(解决方案)

能运行.html文件。。就是不能运行PHP

超时……,
php启动了没……

貌似是php-fpm进程没有启动,没在windows下以cgi方式运行过php,还真不太清楚。


不是php-cgi.exe -d 启动么。 我是网上看的教程。。。
PHP还需要启动?

有两种方法让php运行在web环境中:
1 php以dso模块方式运行在http server上。http server一启动,就会调用php的动态链接库(windows上的*.dll或unix上的*.so)文件,将其作为apache的一个模块来运行。貌似我用过的只有apache支持这种方式。

2 php以cgi方式运行,独立运行一个进程,占用127.0.0.1:9000端口。然后通过http server的反向代理来访问。nginx貌似只支持这种方式,apache两种都支持。

你的情况貌似是php-cgi或php-fpm没启动成功。

青蛙哥。。。 第二种方法咋实现? 我按照网上教程一直无法成功。 提示我9000端口没有开启。 有什么工具能自己开端口的?

查了一下,确实是类似c:/php5/php-cgi.exe -b 127.0.0.1:9000 -c c:/php5/php.ini这样在windows上启动php-cgi.

运行完毕后,netstat -an,看一下是否有



你是不是运行完之后就把这个cmd窗口给关了?

不能关那个,关了那个进程就结束了。

。。。。确实这样操作了就关了。。显示监听就是开启了这个端口是吧。。

PHP页面运行超时。貌似服务是起来了,我去查查啥原因。一直在请求。没返回结果

终于跑起来了。感谢蛙哥

是什么原因搞定的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn