为django开发环境配置端口,以便可以从外部访问该站点
我正在试验 django,并将代码扔到我的服务器上,就像 django book 2.0 的第一章中所解释的那样。
我也在此服务器上运行 apache(端口 80)。 来启动我的 django 站点,
sudo python manage.py runserver 0.0.0.0:80
如果我停止 apache,我可以通过调用“如果我从另一台机器访问它”
http://myservername:80
它工作正常。现在,apache正在运行一个重要的页面,我不想让apache停止。如何使我的网站在另一个端口上可用?
编辑:我会尝试解释更多:
当 apache 运行时,输入浏览器的地址字段,会显示“重要的网页”。
启动我的 django 测试项目
sudo python manage.py runserver 0.0.0.0:anotherport
并尝试访问它
http://ipadressofserver:anotherport
是行不通的。
如果 apache 关闭,并且我启动我的 django 项目,
sudo python manage.py runserver 0.0.0.0:80
我可以访问它,
http://myservername
http://myservername:80 (the browser changes this to http://myservername/
http://myserverIP and http://myservrIP:80 (The latter resolves in the former).
我在服务器管理方面没有经验,所以请问我,如果有什么具体的我可以告诉你,以帮助我解决问题,请问我,如果可能的话,我会提供信息。
I am experimenting with django and I throw the code on my server like explained in the first chapters of the django book 2.0.
I have apache running on this server, too (port 80). If I stop apache I can start my django site by calling
sudo python manage.py runserver 0.0.0.0:80
If I access it from another machine by
http://myservername:80
it works fine. Now, apache is running an important page, and I don't want to let apache stoped. How do I make mysite available on another port?
Edit: I'll try to explain more:
When apache runs, typing into the adressfield of my browser, shows me the "important wepage".
Starting my django test project with
sudo python manage.py runserver 0.0.0.0:anotherport
and accessing trying to acces it by
http://ipadressofserver:anotherport
does not work.
If apache is tuned off, and I start my django project by
sudo python manage.py runserver 0.0.0.0:80
I can access it by
http://myservername
http://myservername:80 (the browser changes this to http://myservername/
http://myserverIP and http://myservrIP:80 (The latter resolves in the former).
I am not experienced in Serveradministration so please ask me, if there is something specific I can tell you, to help me solve the problem, please ask me, and I'll provide the information - if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够正确配置路由器以指向任何端口。这个问题应该更直接地涉及如何公开要浏览的特定端口。您可以提供有关路由器的任何信息将更有助于解决此问题。
You should be able to configure your router appropriately to point to any port. This question should more directly relate to how do you expose a specific port to be browsed. Any information you could provide about your router would be more helpful to address this.
启动开发服务器时指定不同的端口:
并通过以下方式连接到站点:
Specify a different port when starting the dev server:
and connect to the site via: