Nginx service error-php Tutorial

Source: Internet
Author: User
If the php file is run incorrectly in the nginx service, an error is returned.
The configuration file is as follows:
#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;    #    }    #}}

The error is as follows:
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"
Please answer.


Reply to discussion (solution)

Run the. HTML file .. You cannot run PHP.

Timeout ......,
Php started ......

It seems that the php-fpm process has not been started, and php has not been run in cgi mode in windows. it is really unclear.


Is it php-cgi.exe-d. I am an online tutorial...
Does PHP still need to be started?

There are two ways to run php in the web environment:
1. php runs on the http server as a dso module. When the http server is started, it calls the php dynamic link library (*. dll on windows or *. so on unix) file and runs it as a module of apache. It seems that only apache supports this method.

2. php runs in cgi mode and runs a process independently, occupying Port 127.0.0.1: 9000. Then, access through the reverse proxy of the http server. Nginx seems to only support this method. apache supports both.

It seems that php-cgi or php-fpm is not started successfully.

Frog brother... How to implement the second method? I failed to follow the online tutorial. Prompt that Port 9000 is not enabled. What tools can be used to open ports?

Check it, it is indeed similar to c:/php5/php-cgi.exe-B 127.0.0.1: 9000-c:/php5/php. ini in windows to start php-cgi.

After running, check whether netstat-an exists.



Have you closed the cmd window after running?

You cannot close the process.

.... If this is the case, it will be disabled .. The listener enables this port, right ..

PHP page running timeout. It seems that the service is up. I will check the reason. The request is ongoing. No results returned

It finally ran up. Thank you!

What's the reason?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.