没有与使用vagrant的主机名相关联的地址

时间:2014-12-31 12:23:43

标签: titanium vagrant

我使用laravel homestad开发了后端表单移动应用程序,域名为http://myapp.local:1050,它在brwoser中工作得很完美,但是当试图从appcelerator钛工作室调用这个linl时出现此错误  

{
    "code": -1,
    "error": "Unable to resolve host \"myapp.local\": No address associated with hostname",
    "source": {
        "_events": {
            "disposehandle": {
            }
        },
        "allResponseHeaders": "",
        "apiName": "Ti.Network.HTTPClient",
        "autoEncodeUrl": true,
        "autoRedirect": true,
        "bubbleParent": true,
        "connected": false,
        "connectionType": "GET",
        "domain": null,
        "location": "http://myapp.local:1050/index.php?route=api%2Fsetting&api_key=XbUP6ggYuYzbpTJ7YAsqcyoMdEglHxbfPv...",
        "password": null,
        "readyState": 1,
        "responseData": null,
        "responseText": "",
        "responseXML": null,
        "status": 0,
        "statusText": null,
        "timeout": 10000,
        "username": null,
        "validatesSecureCertificate": false
    },
    "success": false
} 

  

无法解析主机\" myapp.local \":没有与主机名关联的地址

为什么看不到主机名myapp.local?

编辑:

  

Homestead.yaml文件

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: /Users/abdellatifhenno/.ssh/id_rsa.pub

keys:
    - /Users/abdellatifhenno/.ssh/id_rsa

folders:
    - map: /Users/abdellatifhenno/projects
      to: /home/vagrant/Code

sites:

    - map: myapp.local
      to: /home/vagrant/Code/myapp





variables:
    - key: APP_ENV
      value: local
  

我的机器(osx 10.9.5)/ etc / hosts文件

<pre>

127.0.0.1   localhost

127.0.0.1 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 hl2rcv.adobe.com

127.0.0.1  myapp.local



255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

</pre>

1 个答案:

答案 0 :(得分:2)

编辑应用程序监听的端口,这样您就可以使用ip地址访问您的应用程序。

sudo vim /etc/nginx/sites-available/myapp.local

change port 80 to 9080 for example 
save your changes

sudo service nginx restart

现在尝试通过IP地址127.0.0.1:9080

访问它

您应该可以使用新端口访问您的网站

好运