How to run real server url with django
PHP中文网
PHP中文网 2017-05-24 11:35:13
0
2
726

Let’s talk about the environment first
centos6.8
python3.5.2
nginx forgot

Then I set everything up on the server
Also created a test file using python manage.py startapp apptest

coding:utf-8 (there is a # in front of it, there is a format problem)

from django.http import HttpResponse

def index(request):

return HttpResponse(u"欢迎!")  

I also successfully output the welcome at www.xxxxxx.cn:8000/app. This is my real website address

But this is based on running the statement python manage.py runserver 0.0.0.0:8000 to access the URL

This is my first time using Django. I used to write PHP before. However, there are some open source libraries that only support Python, so now I encounter this problem. Please give me some advice. Thank you

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
漂亮男人

PHP It is true that as long as an environment similar to LAMP is set up, the website can be launched by directly accessing the PHP file.

But PYTHON is different. The standard startup method is indeed the command line you use. Of course, this performance is relatively poor. In practice, a server like Gunicorn will be used instead. However, the principle is the same. It is started with the command line and in the background, and then accessed to use the link.

The working principle is slightly different from PHP.

过去多啦不再A梦

Generally, to configure Django in a production environment, you need to use apache or nginx + wsgi + django. The web page request first goes to nginx, and after the server processes it (for example, static files, etc.), the request is then processed by wsgi, and then goes to the url in django to find the view, find the tem, etc.
You need to know how to configure nginx, search a lot of information, configure the domain name you bought in nginx config and point it to the django project address, and then point to nginx canfig in the wsgi file in django. No need to run runserver

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template