如何在我的服务器之外查看 django 主页
我刚刚安装了 django 和 python 2.7。创建初始项目后,它说要检查
http://127.0.0.1:8000/
但那是我的 VPS 服务器,我无法在那里打开浏览器。
我尝试了 http://vpsIPaddress:8000
但没有成功
I have just installed django with python 2.7. After creating intitial project it says to check at
http://127.0.0.1:8000/
But that is my VPS server and i can't open browser there.
i tried http://vpsIPaddress:8000
but it didn't worked
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下命令启动您的服务器:
然后,开发服务器将绑定您的服务器上所有可能的IP地址,这是一种方便的测试方法:)
You can start your server with following command:
Then, the dev server will bind all the possible ip address on your server which is a convenient way for test :)
当您在开发模式下启动服务器时,只能通过
localhost
/127.0.0.1
访问它。也就是说,如果您遇到端口冲突,您可以更改它使用的端口:然后您可以通过以下方式访问开发服务器:
值得重申的是,开发服务器将无法从远程主机访问,以阻止您在以下情况中使用它:生产环境,它不适合。如果您需要能够从远程主机访问 Django 应用程序,则需要将应用程序部署到 Apache2 与 mod_wsgi。
When you start your server in development mode, it is ONLY available via
localhost
/127.0.0.1
. That said, if you have a port conflict, you can change the port it uses:And then you can access the development server via:
It's worth reiterating that the development server will NOT be available from remote hosts, to discourage you from using it in a production environment, which it is not suited for. If you need to be able to access your Django app from a remote host, you need to deploy your application to something like Apache2 with mod_wsgi.
我最近在使用 python 开发服务器运行我的服务器时遇到了这个问题。看完这个答案,我差点就打算改用nginx了。我在网上看到有人说你
也可以输入IP地址而不是主机名。这有效。我刚刚测试过。
I recently faced this issue while running my server using python development server. After reading the answer, I almost was going to switch to nginx. Someone on the web I saw that your can
you can also put the ip address instead of the host name. This works. I just tested it.