how to view “localhost” on my iPod touch

前端 未结 8 1675
情深已故
情深已故 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:26

    If you just want a better feel of the native behavior instead of just browser dev tools you can use the iOS simulator and type localhost:xxxx in safari app.

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

    Following these steps worked for me:

    https://mtm.dev/iphone-localhost-mac

    It is based on Internet Sharing via USB and setting & using the device_name which is then used as mentioned as <device_name>.local:<port>

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

    Assuming that your development machine is called my-macbook-pro, you should just be able to navigate to http://my-macbook-pro.local/mywebsite on your iPhone.

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

    I'm working with xampp. localhost works on port 8080. I just find my ip with ipconfig and surf to http://10.0.0.1:8080. That easy!

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

    For OSX, go to System Preferences / Sharing. There, you can find and change the name of your computer. In the same section, you also have to enable "Internet Sharing" service with "iPhone USB" port.

    Then you can view your website at http://{ computer_name }.local/my-website.

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

    100% working solutions

    (for linux + apache + vhosts)

    If you are using vhost (several sites on the same server apache) the next several tips can help you view your local websites on mobile:

    1) VHOST edit -You should go to /etc/apache2/sites-available/ on your server. There can be several files .conf, each file contain a virtual host configuration for apache. Default file will look like 000-default.conf. Open it (or another one) with admin permissions sudo. In that file you should see something like this:

     <VirtualHost *:80>
            ServerName auction.dev
            ServerAdmin test@test.com
            DocumentRoot /var/www/public_html/html
            ErrorLog /var/www/logs/error.log
            CustomLog /var/www/logs/access.log combined
     </VirtualHost>
    

    2) XIP.IO - this special service (its totally free) can help you. You should add to .conf file next line - ServerAlias auction.dev.*.xip.io, after this operation your file will look like this:

    <VirtualHost *:80>
                ServerName auction.dev
                ServerAlias auction.dev.*.xip.io
                ServerAdmin test@test.com
                DocumentRoot /var/www/public_html/html
                ErrorLog /var/www/logs/error.log
                CustomLog /var/www/logs/access.log combined
    </VirtualHost>
    

    After editing you should save this file and restart apache with command sudo apachectl restart.

    3) View from mobile - You need to know ip of your server, in my situation ip = 192.168.1.247. Now in your mobile browser just type auction.dev.192.168.1.247.xip.io and you should see your local website.

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