LNMP environment Local 2 different domain names call each other

Source: Internet
Author: User
Keywords Php
My local environment is LNMP
There are now 2 sites www.aa.com The other is api.aa.com is mainly to provide API interface
I am now www.aa.com this site to invoke the Api.aa.com interface. I'm calling through PHP's Curl mode.
But always prompt www.aa.com always loaded, if I set timeout time to 1s, is ok, meaning I can not get to api.aa.com this domain name below the return value

If I change the local environment to Apache, then I will not encounter the above problems ... I pre-release the test environment without encountering this problem ...
Preliminary conjecture: Is not nginx inside a PHP process is not always in the suspended state? My local is win development environment does not look at other processes and the like is also inconvenient, so ask for advice on this problem solving method 3q

Reply content:

My local environment is LNMP
There are now 2 sites www.aa.com The other is api.aa.com is mainly to provide API interface
I am now www.aa.com this site to invoke the Api.aa.com interface. I'm calling through PHP's Curl mode.
But always prompt www.aa.com always loaded, if I set timeout time to 1s, is ok, meaning I can not get to api.aa.com this domain name below the return value

If I change the local environment to Apache, then I will not encounter the above problems ... I pre-release the test environment without encountering this problem ...
Preliminary conjecture: Is not nginx inside a PHP process is not always in the suspended state? My local is win development environment does not look at other processes and the like is also inconvenient, so ask for advice on this problem solving method 3q

The solution to the problem is to test. You can use the trial httping locally to do a separate api.aa.com for the appropriate time test. If there is no performance test, you can also use PHP, call Get_content_file to do. Time stamp before and after printing
If it is api.aa.com the corresponding time is slow to test the simple index.php page inside the Echo statement words. Do the test. If you can't pass the test, it's basically a server configuration problem.
If you pass, look for api.aa.com database calls, compare simple data calls, and then do business testing.
In addition landlord do not suspect is curl and nginx problem, if you have to suspect also do the corresponding test, pay attention to test method. Nginx support concurrency, unless you set the concurrency is too small, or the Linux system open the number of files is too small. Curl itself is a PHP module that is not part of the PHP kernel and is a PHP-hosted process.

See if it's a domain name resolution.
Try to be a host.
Change/etc/hosts
127.0.0.1 api.aa.com

Try today, the code to test environment OK test environment is nginx, the cause of the error should be local environment win is no php-fpm another local switch to Apache all 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.