After setting up Apache virtual hosts with hostnames "server1" and "server2", how would I access them with my iPhone (or any mobile device) since there's no way modify the /etc/hosts file in iOS or Android?
My understanding is that you have to reference the virtual hosts by name (assuming you only have 1 IP address on your physical server), but there's no way to map those virtual hostnames to the single IP address on my physical server.
I'm running my server on my laptop using MAMP and my Vonage router/Apple Airport don't support DNS. Do I need to setup a local DNS server? Is there any easy way to run that on my laptop? Thanks.
Adding as following
httpd-vhosts.conf
<VirtualHost *:8080>
ServerAdmin [email protected]
DocumentRoot "/opt/lampp/htdocs/api/www"
ErrorLog "logs/app_error"
CustomLog "logs/app_log" common
</VirtualHost>
httpd.conf:
Listen 80
Listen 8080
Then in your mobile you can use:
http://<your laptop address>:8080/
You can't if you don't have a local DNS. As a workaround, you could setup your first VirtualHost to listen on the 80 port and the second one on the 81 (or 8080 or whichever ports you want) and access the server by using http://your.server.ip.addr:port.
You could use IP aliasing and configure IP-based virtual hosts. But then you have to access the sites via IP from your mobile device. But I guess using different ports as @Renaud suggests is easier.
If you want to do it, add an IP alias using ifconfig <interface> inet <ip> add
on Mac OS X. Then add a Listen <ip>
and <VirtualHost ip>
directive to your Apache configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With