【问题标题】:Vagrant port not exposed流浪端口未暴露
【发布时间】:2018-03-14 10:28:11
【问题描述】:

我正在使用ubuntu/xenial64 vagrant 框并按照here 指示的说明设置readthedocs 服务器。

我还在Vagrantfile中硬编码一个静态私网IP:

  config.vm.network "private_network", ip: "192.168.33.10"

但是,在启动Django 服务器后:

(rtd) vagrant@ubuntu-xenial:~/rtd/checkouts/readthedocs.org$ python manage.py runserver
[14/Mar/2018 05:22:40] root:120[1581]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[14/Mar/2018 05:22:40] root:120[1581]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[14/Mar/2018 05:22:41] root:120[1585]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[14/Mar/2018 05:22:41] root:120[1585]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Performing system checks...

System check identified some issues:

WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG.
?: (guardian.W001) Guardian authentication backend is not hooked. You can add this in settings as eg: `AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'guardian.backends.ObjectPermissionBackend')`.

System check identified 2 issues (1 silenced).
March 14, 2018 - 05:22:42
Django version 1.9.12, using settings 'readthedocs.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

我无法访问http://192.168.33.10:8000/

vagrant 机器内:

vagrant@ubuntu-xenial:~$ netstat -ta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:ssh                   *:*                     LISTEN     
tcp        0      0 localhost:8000          *:*                     LISTEN     
tcp        0      0 localhost:6379          *:*                     LISTEN  

使用

$ vagrant --version
Vagrant 2.0.2

Virtualbox 5.2.8 r121009 (Qt5.6.1)Ubuntu 16.04.03 主机上。

【问题讨论】:

    标签: django vagrant read-the-docs


    【解决方案1】:

    文档末尾都有详细说明

    要使构建按预期正确启动,端口是必要的 您正在服务(即runserver 0.0.0.0:8080)与定义的端口匹配 在PRODUCTION_DOMAIN。您可以使用local_settings.py 进行修改 这个。 (默认为localhost:8000

    您可以选择以下两种方法之一:

    • python manage.py runserver 0.0.0.0:8080启动服务器
    • 更新 local_settings.py 并将 localhost:8000 更改为 0.0.0.0:8080

    您还可以将0.0.0.0 替换为您为虚拟机配置的 IP

    【讨论】:

    • 感谢您完成了这项工作;然而,在启动 web ui 并尝试使用我的Django 超级用户帐户登录后,它要求我验证我的电子邮件地址(我当然不能,因为这个本地实例没有连接到任何邮件服务器)。不验证邮件可以登录吗?
    • 对,我不熟悉将 Django 与本地邮件服务器连接,如果没有相同主题的帖子,您可能应该为此创建另一个帖子
    猜你喜欢
    • 2019-06-04
    • 2018-09-03
    • 2021-12-16
    • 2017-05-07
    • 1970-01-01
    • 2019-10-24
    • 2020-02-22
    • 2019-06-22
    • 1970-01-01
    相关资源
    最近更新 更多