It sounds like you're confused regarding what localhost is. Localhost is always local: this is the machine itself and has 127.x.x.x
as an IP address (usually 127.0.0.1
).
If you run MAMP on your Mac, connection to localhost
from your iPhone or any other device will be of no use. As far as your iPhone is concerned, localhost
is the iPhone itself.
If you want to run a test server within your LAN, which probably uses private addresses (typically, 192.168.0.x
), you'll need to configure your server for the IP address the machine on which it's running is using (you can normally see this in the network preferences).
As far as Apache Httpd is concerned, this will have to be configured in a VirtualHost
(matching that LAN IP address). It's not quite clear what you're after: this is just how Apache Httpd is meant to be configured anyway.
The problem you're going to encounter is that your certificate will need to be valid for that IP address. It's in fact often simpler to allocate a host name (some routers provide small DNS services for the machine for which they also run a DHCP service, for example), and it generally makes more sense. Nevertheless, you can generate a certificate valid for an IP address by using an IP address Subject Alternative Name (SAN) entry (as discussed in this answer, see OpenSSL section). This also implies that you'll need to use your own self-signed certificate or your own mini Certification Authority, and that you'll have to import it somehow into your iPhone for the server certificate to be trusted.