Use hosts file with shared IP address?
My Linode has one IP. All of my domains share that IP.
For development I'd like to by-pass the normal DNS system and hit a domain via the IP in the local (macOS) hosts file.
That can't be done with a shared IP (except for the one domain the IP defaults to.)
So… is there anything I can put in the Apache virtual host file that might make it unique that my local hosts file will accept?
I doubt it, but thought I'd ask.
5 Replies
So… is there anything I can put in the Apache virtual host file that might make it unique that my local hosts file will accept?
No, but this is what you can do:
- in /etc/hosts (on the machine where you run your browser):
aaa.bbb.ccc.ddd mysite.com.local
- in apache24 config:
<VirtualHost _default_:80>
ServerName mysite.com.local
...
</VirtualHost>
Then you access your development site as http://mysite.com.local .
It's not ideal but you only have to change one line (ServerName) when you move your site to production.
-- sw
You can also run an apache2 server on your Mac. It's available on homebrew (https://brew.sh ). The apache2 manipulation commands:
- a2{en,dis}mod
- a2{en,dis}site
- a2{en,dis}conf
from Linux are perl scripts that are pretty easy to port too. perl5 is available on your Mac as well. I know all this because I've done all this.
I have an HP 800 EliteDesk G3 in my living room that powers my development environment, so I chucked all the Mac stuff and moved my all development activities to the G3 long ago.
-- sw
You can also run an apache2 server on your Mac
Could I use MAMP (which I use often for local development before I deploy to a server)?