我遇到了hosts文件和PHP的問題。當運行PHP代碼爲root
時,將讀取/ etc/hosts中的條目。但是,不要以我的用戶或Apache的身份運行代碼。/etc/hosts不影響PHP
[email protected]:/# cat /etc/hosts
127.0.0.1 mydomain.com
[email protected]:/# php -r "echo gethostbyname('mydomain.com');"
127.0.0.1
[email protected]:/$ php -r "echo gethostbyname('mydomain.com');"
xxx.xxx.xxx.xxx
任何想法,爲什麼這是?
我不認爲這屬於serverfault,因爲PHP參與:) – Znarkus 2010-07-16 11:20:57