开发者

/etc/hosts doesn't affect PHP

开发者 https://www.devze.com 2023-01-07 09:24 出处:网络
I\'m having problems with the hosts file and PHP. When running the PHP code as root, the entries from /etc/host开发者_JAVA百科s are read. But not when running the code as my user, or from apache.

I'm having problems with the hosts file and PHP. When running the PHP code as root, the entries from /etc/host开发者_JAVA百科s are read. But not when running the code as my user, or from apache.

root@server:/# cat /etc/hosts
127.0.0.1       mydomain.com

root@server:/# php -r "echo gethostbyname('mydomain.com');"
127.0.0.1

markus@server:/$ php -r "echo gethostbyname('mydomain.com');"
xxx.xxx.xxx.xxx

Any idea why this is?


Did you make sure your /etc/hosts file is world readable?

chmod a+r /etc/hosts

0

精彩评论

暂无评论...
验证码 换一张
取 消