Domain name resolution failure in PHP

Source: Internet
Author: User

Pay attention to the use of the VM panel management system, especiallyAmhPanel !!

After installing the amh panel, all functions that use domain name resolution fail, such as gethostbyname, curl, and email. If the url is a domain name, all functions fail, you can change it to an IP address. At first, I thought it was a dns problem. I checked it and used 8.8.8.8.8 and 8.8.4.4. In addition, the IP address can be returned even if I ping those domain names, and nslookup is normal, the most strange thing is to use the terminal command line terminal to run:

# Php-r "echo (gethostbyname ('www .baidu.com '));";

The ip address can be returned, so the target is targeted at amh. It should be a problem. I have been searching for the Internet for a long time. I have asked many people that I have not found a solution, later, I accidentally learned about the chroot thing. Baidu once found that it switched the system environment to a specified directory, and the system environment outside the directory was useless, including dns resolution, it began to become clearer, so I checked which lib needs to be used for dns resolution, mainly these three:

Libnss_dns.so.2 libnss_files.so.2 libresolv. so.2

Now, the point is,Amh panelCd to your VM Directory:/home/wwwroot/xxx.com/, which contains directories such as etc, lib, usr, web, and tmp, copy the three lib mentioned above to the lib of your VM directory

# Cp/lib/i386-linux-gnu/libnss _ */home/wwwroot/xxx.com/lib/

Now, try again. Is it successful?

Alas, tears are everywhere...

-----------------------------

PS: Remember to restart php after completing the last step,Amh, Direct command:

# Amh php restart xxx.com

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.