Two different local domain names in the lnmp environment call each other

Source: Internet
Author: User
My local environment is lnmp. Now I have two sites www.aa.com, and the other is api.aa.com, which mainly provides api interfaces. Now I want the site www.aa.com to call the api.aa.com interface. I called it in php curl mode, but I keep prompting that www.aa.com is being loaded. If my local environment is lnmp
Now there are two sites www.aa.com, and the other is api.aa.com, which mainly provides api interfaces.
I want to call the api.aa.com interface at www.aa.com. I called it in php curl mode.
But I keep prompting that www.aa.com is loading. If I set the timeout time to 1 s, it is OK, which means that I cannot get the returned value under the domain name api.aa.com.

If I change all the local environments to apache, the above problems will not occur ...... I will not encounter this problem in the pre-release test environment...
Preliminary conjecture: Is there a php process in nginx that has been suspended? I am a Windows development environment and it is not convenient to look at other processes, so please advise this problem solution 3q

Reply content:

My local environment is lnmp
Now there are two sites www.aa.com, and the other is api.aa.com, which mainly provides api interfaces.
I want to call the api.aa.com interface at www.aa.com. I called it in php curl mode.
But I keep prompting that www.aa.com is loading. If I set the timeout time to 1 s, it is OK, which means that I cannot get the returned value under the domain name api.aa.com.

If I change all the local environments to apache, the above problems will not occur ...... I will not encounter this problem in the pre-release test environment...
Preliminary conjecture: Is there a php process in nginx that has been suspended? I am a Windows development environment and it is not convenient to look at other processes, so please advise this problem solution 3q

To solve this problem, you can use httping locally to test the api.aa.com time. If the performance test is not performed, you can use php to call get_content_file. Print the timestamp before and after
If api.aa.com is slow, test the echo Statement on the simple index. php page. If the test fails, it is basically a server configuration problem.
If the call is successful, find the api.aa.com database call information, make simple data calls, and then perform business testing.
In addition, do not suspect that the problem is curl or nginx. If you have to doubt it, perform the test. Pay attention to the test method. Nginx supports concurrent operations, unless your concurrency is set too small, or the number of files opened in linux is too small. Curl itself is a php module, not part of the php kernel. It is a php-hosted process.

Check whether the domain name resolution problem exists.
Try to create a host.
Change/etc/hosts
127.0.0.1 api.aa.com

Today, I tried to run the code to the test environment. The OK test environment is also nginx. The cause of the error is that the local environment win is not php-fpm, and the local environment switches to apache. Everything is OK.

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.