how to view “localhost” on my iPod touch

前端 未结 8 1676
情深已故
情深已故 2020-12-16 15:26

I have a website I am building on localhost:

http://localhost/my-website

I need to test it on my iPhone, but I\'m not sure how to go about it. Do I just chan

相关标签:
8条回答
  • 2020-12-16 15:49

    When you connect your ipod with the cable to your macbook the device appears in safari on your mac in the menu under developers. When you click this option you can see exact the same as you can on your ipod.

    0 讨论(0)
  • 2020-12-16 15:51

    To expand slightly on Richard J. Ross III's answer, "localhost" is a name used to refer only to the local computer. In order for your iPhone to be able to access content on that machine it must:

    1. Have an IP address on the same network as the server machine.

      This can be achieved by connecting the iPhone to a wireless access point that is on the same network as the PC, or by creating an ad-hoc wireless network between the two devices.

    2. Respond to HTTP requests from network clients.

      Assuming the server and the iPhone are on the same network, it should be possible for traffic to flow between them. However in order for your web content to be visible to the iPhone, the web server must also be configured to respond to requests made to the server machine's IP address.

      This is not normally a problem as web servers are commonly configured to respond to HTTP requests sent to any of the machines IP addresses. It is possible that a server could be configured to only respond to local requests, however this is not a typical default setting

      How you check or modify this setting is dependent upon the HTTP server software you are using. As this information is not specified I will include instructions for Apache2 as this is a very common choice of HTTP server.

    Apache's Listen Directive

    Apache's main configuration file is httpd.conf and it is located in the conf subdirectory of your Apache directory. The location of your Apache root directory will vary depending upon what operating system you are using and whether or not a custom location was chosen at installation.

    The httpd.conf file contains a directive named Listen which controls the interface (IP address and port) on which Apache listens for incomming HTTP requests.

    The default form of this directive is commonly

    Listen 80

    This specifies that the machine will respond on any of it's IP addresses to requests made on port 80, which is the default port for HTTP traffic.

    You can modify the Listen directive to use any address associated with the machine including the loopback address (127.0.0.1) which the name localhost resolves to.

    If Apache is set up to only listen on the loopback address then your server machine will only respond to requests made on the local machine. In this configuration, your Listen directive will look something like:

    Listen 127.0.0.1:80

    If this is the case, you will need to change to either listening on all addresses, as in the example above, or listening only on the address used by the iPhone to communicate with the server machine.

    0 讨论(0)
提交回复
热议问题