1.测试

  1. python manage.py runserver
  2. python manage.py runserver 0.0.0.0
  3. python manage.py runserver 0.0.0.0:8000 --noreload
  4. python3 manage.py runserver 8000

2.error

django POST /style/ HTTP/1.1” 500 145

里面有错误函数里

  1. b'<h1>Not Found</h1><p>The requested resource was not found on this server.</p>' <class 'bytes'>

HTTP/1.1” 301 0

23/Feb/2022 16:47:50] “POST /createPetArchivesFromDogNose HTTP/1.1” 301 0
django.db.utils.IntegrityError: (1048, “Column ‘create_timestamp’ cannot be null”)
https://stackoverflow.com/questions/1579846/django-returning-http-301
https://docs.djangoproject.com/zh-hans/4.0/ref/contrib/redirects/
您可能正在请求不带斜杠的 URL,并且APPEND_SLASH在 settings.py 中设置为 True(默认值),因此 Django 正在重定向到包含斜杠的 URL。

nginx+django 502 bad gateway

修改直接代码上传,本地测试成功,服务端502
查看了cat /usr/local/nginx/logs/error.log uwsgi.log
发现修改代码区少安装包
重启nginx,uwsgi
重启 reboot,nginx,uwsgi

django

uwsgi 有问题

Traceback (most recent call last):

File “./agesite/wsgi.py”, line 16, in
application = getwsgiapplication()
File “/usr/local/lib/python3.6/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application
django.setup(set_prefix=False)
File “/usr/local/lib/python3.6/site-packages/django/__init
.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “/usr/local/lib/python3.6/site-packages/django/apps/registry.py”, line 81, in populate
raise RuntimeError(“populate() isn’t reentrant”)
RuntimeError: populate() isn’t reentrant
unable to load app 0 (mountpoint=’’) (callable not found or import error)
—- no python application found, check your startup logs for errors —-
[pid: 1630|app: -1|req: -1/14] 39.64.235.229 () {44 vars in 905 bytes} [Wed Mar 9 19:02:59 2022] POST /createPetArchivesFromDogNose/ => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core

RuntimeError: populate() isn’t reentrant

This is caused by a bug in your Django settings somewhere. Unfortunately, Django’s hiding the bug behind this generic and un-useful error message.
To reveal the true problem, open django/apps/registry.py and around line 80, replace:
raise RuntimeError(“populate() isn’t reentrant”)
with:
self.appconfigs = {}
重启uwsgi文件
得到错误
django app has no attribute ‘defaultapp_config’
在app module 下创建 __init
.py

nginx

readv() failed (104: Connection reset by peer) while reading upstream, client: 39.64.235.229, server: 127.0.0.1, request: “POST /createPetArchivesFromDogNose/ HTTP/1.1”, upstream: “uwsgi://0.0.0.0:8200”, host: “115.29.104.54:8000”

3.服务器启动流程

  • Ngnix 服务器(django) + uwsgi 配置