Question:
Make Apache Use Hosts File outside etc?
anonymous
2013-10-17 02:50:36 UTC
Hello,

I am a self taught PHP webdeveloper and I am trying to get my portable webserver use a different hosts file usually held within the system folder 'etc' I am trying to get apache to use a custom copy of the hosts file so that not only can I carry my server but all my sub-domains without having to modify the original file in etc.


Any help is greatly appreciated and Thank you in advance


Regards

Harry
Three answers:
?
2013-10-17 12:01:11 UTC
Apache doesn't access the /etc/hosts file directly. It uses a library call (the same one that Firefox and every other app on the system uses) to determine name to address mapping. The library call uses DNS or local hosts file or whatever other method as determined by how you have your system configured.



So you can't have Apache using one thing and the rest of the system using something else.



It is possible to have Apache not use anything, for example, to specify both the name and address of the virtual host in the apache configuration:





ServerName www.myserver1.net

...





ServerName www.myserver2.net

...





However, that only makes apache work, it doesn't help any other application (like Firefox) be able to lookup the names. If you want both apache and firefox to work together then they both have to have the same information.
anonymous
2013-10-17 02:58:08 UTC
First, a portable server is useless. They need a static IP address to be reliable. Second Apache does NOT use the hosts file for anything. All its' configuration is within the Apache configuration folder. It must NEVER have direct access to the hosts file or you might as well sell tickets to hackers and give them logins to the machine. That is one MASSIVE security risk.
Jim
2013-10-17 04:59:14 UTC
http://jesusnjim.com/web-design/setup-test-server.html#portable


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...