1

I'm building a site on my localhost with a virtual host (mynewsite.com). Instead of uploading files to an actual server and I'd prefer to just test locally. I have the virtual host working on my desktop, I just want it to be available so I can see it on my iPhone or any computer on my network. So if I go to mynewsite.com on my iPhone it will display the site from my localhost. I think I need to do port forwarding but I'm having difficulty figuring it out. I'm on a Mac with MAMP.

How do I make the virtual host available to my iPhone through my Linksys router for testing?

My httpd.conf in MAMP looks like:

<VirtualHost *:80>
    DocumentRoot "/Users/jaysonp/Sites/mynewsite"
    ServerName "mynewsite.com"
    ServerAlias *.mynewsite.com
...

Then in my host file I have: 127.0.0.1 mynewsite.com

I should note that I can't just hit the ipaddress on my iPhone, there is code that checks against the domain name for the site to work.

Thanks!

jaysonp
  • 11
  • 1
  • 1
  • 3

4 Answers4

5

Please see my answer here. But basically, you just have to modify the Wifi settings in your iPad to use the IP address of your development machine as an HTTP proxy.

Community
  • 1
  • 1
Stéphane
  • 3,884
  • 1
  • 30
  • 27
1

You can use application to edit hosts file on the devices. Use iFile application. You can add more any hostname. You can see some picture here but I wrote in my language.

http://www.anop72.info/iphoneipad-เรียก-url-vhost-ทำอย่างไร/

Hope this helps.

kapex
  • 28,903
  • 6
  • 107
  • 121
anop72
  • 31
  • 2
-1

You just need to change the host file of respective machine on which you want to see your virtual host.

For Example:

(in Linux and macOS ): /etc/hosts
(in Windows ): c:/windows/system32/drives/etc/hosts
(in Android ): Android is also the part of linux so the host file location is same in android too. But you need root access to change the host file.
(in iOS ): (anyone who knows can edit here!!)

Open the host file and

192.168.1.70    mynewsite.com

192.168.1.70 is the ip address of the machine in which your project is running on a virtual hosting -> mynewsite.com

All of the other devices must be connected to the same network .

Asis
  • 683
  • 3
  • 23
-2

Just use the IP address of your virtual host. If your iPhone is on the same local network as your [virtual] host - the IP address will work fine.

I am not quite sure how you are defining "virtual" host - i.e. are you using Xen or VMware or something - or just running a web service on your dekstop?

If it is the former - you need to set up the IP services through Xen/VMware - if it's the later - its you desktop machine's IP address.

Brad
  • 11,262
  • 8
  • 55
  • 74
  • I have the virtual host setup in my httpd.conf in MAMP. – jaysonp Nov 06 '10 at 17:19
  • Then two options: Make the default host point to your "mynewssite.com" and have your iPhone app use the IP address instead of the name. OR Run your own DNS Server - make that iPhone use it (either be setting your wireless router DHCP, or entering manually on the iPhone) - Make the DNS server resove "mynewsserver.com" to the the IP address of your Host. – Brad Nov 06 '10 at 17:23
  • I'm sorry I'm still a bit confused. It sounds like I need to run my own DNS server because I need use the domain name for the site. Where am I setting the router DHCP? in the router admin? And how do I make a DNS server resolve to "mynewserver.com"? Thanks. – jaysonp Nov 08 '10 at 09:47
  • Yes - your own DNS server. You can either set the DNS pointer in the route admin, or go into the WiFi settings on your iPhone, and for "IP Address" - specify "Static" - and put in all your settings manually - replacing "DNS" with your new server. Alternatively, you can run your own Web Proxy which uses special handing for "mynewsserver.com" - and set you iPhone to use it under the "HTTP Proxy" setting. – Brad Nov 08 '10 at 13:44