为django开发环境配置端口,以便可以从外部访问该站点

发布于 2024-11-11 03:42:38 字数 996 浏览 0 评论 0原文

我正在试验 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山田美奈子 2024-11-18 03:42:39

您应该能够正确配置路由器以指向任何端口。这个问题应该更直接地涉及如何公开要浏览的特定端口。您可以提供有关路由器的任何信息将更有助于解决此问题。

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.

祁梦 2024-11-18 03:42:38

启动开发服务器时指定不同的端口:

$ python manage.py runserver 0.0.0.0:8000

并通过以下方式连接到站点:

 http://myserverip:8000

Specify a different port when starting the dev server:

$ python manage.py runserver 0.0.0.0:8000

and connect to the site via:

 http://myserverip:8000
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文