I have problems with hosts file and PHP. When you run the PHP code, the entries from / etc / hosts are read as root . But not when running the code as my user or from apache.
root
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?
Are you sure your /etc/hosts is readable in the world?
/etc/hosts
chmod a+r /etc/hosts
Source: https://habr.com/ru/post/1315903/More articles:Recording data SURPAY cURL - phpGoogle chart formatting - javascriptusing the System :: Drawing space in a managed C ++ class library - c ++How to crop an image at boot time? - phpIn Rails, how to get the actual request when an ActiveRecord request is executed - ruby-on-railsSSRS Web Service LoadReport () Exception: - c #Multidimensional arrays in php - arraysHow do I add a simple menu to a Rails application? (How to use output: menu) - ruby-on-railsInsert data into a file in c - cArguments in the function prototype - c ++All Articles