远程服务器上的Django教程:如何在浏览器中查看? [英] Django tutorial on remote server: how to view in my browser?
问题描述
[背景信息]
我已经做了,显然是成功的是
django-admin.py startproject mysite
(创建的mysite目录包含四个文件)
python manage.py runserver
(验证模型..发现0错误等)
绝对路径是
/ home / toewsweb / public_html / pythonlab / mysite
我应该使用什么URL我可以在浏览器中使用它吗?
我还把mysite放在
/ home / toewsweb / mysite(因为它不应该在可公开访问的目录)
在这种情况下,我应该使用什么URL?
这是一个虚拟专用服务器,所以我可以访问httpd.conf 。我已经下载并安装了mod_wsgi并将其添加到Apache配置中。我实际上设置了一个具有/ home / toewsweb / public_html / pythonlab / mysite的DocumentRoot的子域;然而,当我将浏览器指向该子域名时,我只需要找到目录列表。
[/背景信息]
谢谢!
现在,我只想知道如何查看我在浏览器中工作的内容。 div class =h2_lin>解决方案
出于开发的目的,不需要混淆配置WSGI(尽管知道这一点很有用,因为您需要做生产)。只需启动dev服务器,以便它侦听一个外部端口:
./ manage.py runserver 0:8000
这绑定到外部IP地址,所以现在您可以通过该服务器上的端口8000访问您的Django站点: / p>
http://whatever.my.ip.is:8000
I'm getting started with a Django tutorial, and I've run into a snag. Having created the sample "mysite" on my usual domain, I want to be able to display it in my browser. The tutorial points me to http://127.0.0.1:8000. However, that's not going to work, as I'm doing this remotely.
[background information]
What I have done, apparently successfully, is django-admin.py startproject mysite (created mysite directory containing four files) python manage.py runserver (Validating models... 0 errors found, etc.)
The absolute path is /home/toewsweb/public_html/pythonlab/mysite What URL should I be able to use to bring this up in my browser?
I also put mysite at /home/toewsweb/mysite (since it's not supposed to go in a publicly accessible directory) What URL should I be able to use in this case?
This is a virtual private server, so I have access to httpd.conf. I have downloaded and installed mod_wsgi and have added it to the Apache configuration. I actually did set a subdomain with a DocumentRoot of /home/toewsweb/public_html/pythonlab/mysite; however, when I point the browser to that subdomain, I just get the directory listing.
[/background information]
Right now, I just want to know how to view what I'm working on in my browser.
Thanks!
For development purposes, there's no need to mess about with configuring WSGI (although it's useful to know, as you will need to do it for production). Just start the dev server so that it listens to an external port:
./manage.py runserver 0:8000
This binds to the external IP address, so now you can access your Django site via port 8000 on that server:
http://whatever.my.ip.is:8000
这篇关于远程服务器上的Django教程:如何在浏览器中查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!