Phpstudy Nginx under Curl request local other project

Source: Internet
Author: User

When curl requests, if you use a POST request, the header will be set to Multipart/form-data if it is a string, and header header will be set to Application/x-www-urlencode

When using an array to pass a value, Php://input is not receiving data?

Today, there is a problem in the project, a site called B Site B site called the remote C site. There is always a timeout in the curl return value, and there are two types of curl timeouts

One is the connection timeout and the other is the maximum allowable time for the data transfer.

The connection time-out is specified with the--connect-timeout parameter, and the maximum allowable time for data transfer is

If the connection times out, the error message is as follows:

Curl: (+) Connect () timed out!

When the maximum allowable time for data transfer expires, the error message is as follows:

Curl: (operation) timed out after 0 bytes received milliseconds

I just showed up today. The second reason is that both A and B sites are configured locally, and my local phpstudy is nginx.

The Fastcig-pass setting value (127.0.0.1:9000).

The settings are requested in keepalive mode, and when the PHP file is received, it is submitted to the backend process phpcgi parsing processing (127.0.0.1:9000), waiting for the response.

While the local file with Curl requests the PHP file in the local environment, the previous PHP is still waiting for the result after curl, when the 9000 port is already occupied. Causes curl to remain in the waiting state. Set the time-out period

Curl_setop ($ch, curlopt_timeout,20), after the timeout time, returns Curl: (0) operation timed out after the milliseconds with a bytes received

My? Solution

Change the server fastcgi port on site B to 9003

Open cmd

Php-cgi.exe-b 127.0.0.1:9003-c php.ini Run this command but the CMD command window cannot be closed.

The following excerpt from the network

The above with the CMD Command Line window is not very troublesome, not to close the window, a little less attention on the tragedy

You can use one of the following gadgets: Runhiddenconsole

First you need to download a small file runhiddenconsole then copy to the Nginx directory, create a new two bat batch file, Start_nginx.bat and Stop_nginx.bat

Note: RunHiddenConsole.exe must be with two batch files in the same level directory, or nginx can not boot

Specific two files how to write the attachment has been written, direct download will be OK

The first step:

Change the Fastcgi_pass of one item in vhost.conf to 9001

Location ~ \.php (. *) $ {            fastcgi_pass   127.0.0.1:9001;}

  

CMD run

D:\Program Files (x86) \php\php-7.0.12-nts>php-cgi.exe-b 127.0.0.1:9001-c php.ini

Test Send request again

Phpstudy Nginx under Curl request local other project

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.