从外部访问本地主机?
Accessing localhost externally?
这可能是一个非常基本的问题。我 SSH 到我的虚拟 Ubuntu 服务器并在本地主机上启动一个 django 网络服务器 运行:
Downloading/unpacking django
Downloading Django-1.9.5-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
April 13, 2016 - 14:16:19
Django version 1.9.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Ubuntu 服务器有一个静态 IP [x.xxx.xxx.xxx] 所以我尝试从另一个网络上的另一台机器使用该静态 IP 地址在浏览器中访问上述网站:
x.xxx.xxx.xxx:8000
但我得到:
This site can’t be reached
x.xxx.xxx.xxx refused to connect.
ERR_CONNECTION_REFUSED
所以我假设我无法访问这样的网站,即使主机有 external/static IP 地址,它也只能在它自己的主机上访问?
编辑:
答案也在:
https://docs.djangoproject.com/en/1.9/intro/tutorial01/#the-development-server
python manage.py runserver 0.0.0.0:8000
这可能是一个非常基本的问题。我 SSH 到我的虚拟 Ubuntu 服务器并在本地主机上启动一个 django 网络服务器 运行:
Downloading/unpacking django
Downloading Django-1.9.5-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
April 13, 2016 - 14:16:19
Django version 1.9.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Ubuntu 服务器有一个静态 IP [x.xxx.xxx.xxx] 所以我尝试从另一个网络上的另一台机器使用该静态 IP 地址在浏览器中访问上述网站:
x.xxx.xxx.xxx:8000
但我得到:
This site can’t be reached
x.xxx.xxx.xxx refused to connect.
ERR_CONNECTION_REFUSED
所以我假设我无法访问这样的网站,即使主机有 external/static IP 地址,它也只能在它自己的主机上访问?
编辑:
答案也在: https://docs.djangoproject.com/en/1.9/intro/tutorial01/#the-development-server
python manage.py runserver 0.0.0.0:8000