Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access my MAMP websites (plural) locally from my iphone

I have created a few websites locally on my mac using MAMP PRO as my local server environment.

I can access these on my mac as I have the opion of adding a local domain (in MAMP PRO) using "local name resolution"

But... I don't know how to access my sites from my iphone which I need to do to test.

If I put my local IP in (on my iphone) I get the MAMP holding page:

The virtual host was set up successfully.

If you can see this page, your new virtual host was set up successfully. Now, web contents can be added and this placeholder page1 should be replaced or deleted.

Server name: localhost Document-Root: /Applications/MAMP/htdocs

So I know that works but how do I access my indevidual sites.

The location and structure of my sites are like this:

/Users/myusername/Sites/vhosts/site1/public_html
/Users/myusername/Sites/vhosts/site2/public_html
/Users/myusername/Sites/vhosts/site3/public_html
/Users/myusername/Sites/vhosts/site4/public_html

Could this be to do with the localhost Document-Root? I noticed it was /Applications/MAMP/htdocs

Should I change that or change the location of my sites to be in /Applications/MAMP/htdocs?

Thanks C

UPDATE:

Ok, so I changed my Document-Root to /Users/myusername/Sites/vhosts/ which now allows me to load the site localy in my browser with 192.168.1.134/site1/public_html

BUT.. when I load 192.168.1.134/site1/public_html from my iphone (on the same wifi network) I get the page title but the page doesn't load. Just hangs!

like image 753
Cybercampbell Avatar asked Oct 27 '25 14:10

Cybercampbell


1 Answers

I use ngrok to forward my localhost and would recommend it. After installing it (it's free), you essentially run something like "ngrok 80" and ngrok will create a public URL that can be accessed from anywhere (AKA your phone) and displays the same content that http://localhost/ would.

Apologies I can't post full http:// links- I'm limited by my reputation.

In your example, ngrok might create a domain "hs673gs.ngrok.com" that corresponds to "localhost" when accessed from your local machine. Going to "hs673gs.ngrok.com/site1/public_html" from your iPhone will be essentially the same as visiting "192.168.1.134/site1/public_html" on your local machine.

Hope this helps.

like image 189
WuddupDok Avatar answered Oct 29 '25 09:10

WuddupDok