Skip to main content
 首页 » 编程设计

python之django 和 uwsgi + nginx 中的内部服务器错误

2024年12月31日28dyllove98

我在服务器上部署了一个 Django 应用程序。 我使用 nginx 和 uwsgi 作为网络服务器。 一开始我没有遇到任何问题,但是当我将 rest_framework 添加到项目时,我看到了“内部服务器错误”。我猜它有 rest_framework 的问题,但我不知道它的原因。我想你应该知道当我从项目中删除 rest_framework 时,它正在工作。

我应该说,当我使用 python manage.py runserver 运行项目时,它正在运行。我猜 nginx 或 uwsgi 有什么问题。

我把我的设置放在下面:

settings.py

import os 
 
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
 
# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = 'SECRET_KEY' 
 
# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = False 
 
ALLOWED_HOSTS = ["*"] 
 
 
# Application definition 
 
INSTALLED_APPS = [ 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.sites', 
    'tagulous', 
    'django_render_partial', 
    'ckeditor', 
    'ckeditor_uploader', 
    'allauth', 
    'allauth.account', 
    'allauth.socialaccount', 
    # 'easy_thumbnails', 
    # 'filer', 
    'mptt', 
    # 'anymail', 
    'core.apps.CoreConfig', 
    'blog.apps.BlogConfig', 
    'sitebuilder.apps.SitebuilderConfig', 
    'rest_framework', 
 
] 
 
MIDDLEWARE = [ 
    'django.middleware.security.SecurityMiddleware', 
    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.middleware.common.CommonMiddleware', 
    'django.middleware.csrf.CsrfViewMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'django.middleware.clickjacking.XFrameOptionsMiddleware', 
] 
 
ROOT_URLCONF = 'boofeh.urls' 
 
TEMPLATES = [ 
    { 
        'BACKEND': 'django.template.backends.django.DjangoTemplates', 
        'DIRS': [os.path.join(BASE_DIR, 'sitebuilder','templates'), os.path.join(BASE_DIR, 'sitebuilder','templates', 'allauth')], 
        'APP_DIRS': True, 
        'OPTIONS': { 
            'context_processors': [ 
                'django.template.context_processors.debug', 
                'django.template.context_processors.request', 
                'django.contrib.auth.context_processors.auth', 
                'django.contrib.messages.context_processors.messages', 
            ], 
        }, 
    }, 
] 
 
WSGI_APPLICATION = 'boofeh.wsgi.application' 
 
 
# Database 
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases 
 
# DATABASES = { 
#     'default': { 
#         'ENGINE': 'django.db.backends.sqlite3', 
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
#     } 
# } 
 
DATABASES = { 
    'default': { 
        'ENGINE': 'django.db.backends.postgresql_psycopg2', 
        'NAME': 'boofeh', 
        'USER': 'boofehuser', 
        'PASSWORD': '123456', 
        'HOST': 'localhost', 
        'PORT': '', 
    } 
} 
 
# Password validation 
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 
 
AUTH_PASSWORD_VALIDATORS = [ 
    { 
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 
    }, 
    { 
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 
    }, 
    { 
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 
    }, 
    { 
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 
    }, 
] 
 
 
# REST_FRAMEWORK = { 
#     'DEFAULT_AUTHENTICATION_CLASSES': ( 
#         # 'rest_framework.authentication.TokenAuthentication', 
#         'rest_framework.authentication.SessionAuthentication', 
#         'rest_framework.authentication.BasicAuthentication', 
#     ), 
#     'DEFAULT_PERMISSION_CLASSES': ( 
#         'rest_framework.permissions.IsAuthenticatedOrReadOnly', # if the users haven't logged in then they can use it as read only. 
#     ) 
# } 
 
 
# Internationalization 
# https://docs.djangoproject.com/en/2.0/topics/i18n/ 
 
LANGUAGE_CODE = 'en-us' 
 
TIME_ZONE = 'UTC' 
 
USE_I18N = True 
 
USE_L10N = True 
 
USE_TZ = True 
 
 
# Static files (CSS, JavaScript, Images) 
# https://docs.djangoproject.com/en/2.0/howto/static-files/ 
 
STATIC_ROOT = os.path.join(BASE_DIR, "static") 
STATIC_URL = '/static/' 
 
MEDIA_URL = '/uploads/' 
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') 
 
SITE_ID = 1 
 
 
SERIALIZATION_MODULES = { 
    'xml':    'tagulous.serializers.xml_serializer', 
    'json':   'tagulous.serializers.json', 
    'python': 'tagulous.serializers.python', 
    'yaml':   'tagulous.serializers.pyyaml', 
} 
 
 
CKEDITOR_UPLOAD_PATH = "ckeditor/" 
 
 
CKEDITOR_CONFIGS = { 
    'default': { 
        'toolbar': 'full', 
    }, 
} 
 
LOGIN_REDIRECT_URL = '/users/profile' 

/etc/uwsgi/sites/boofeh.ini

[uwsgi] 
project = boofeh 
envname = boofehenv 
base = /home/ 
envbase = /root/ 
uid = root 
 
chdir = %(base)/%(project) 
home = %(envbase)/Env/%(envname) 
module = %(project).wsgi:application 
 
master = true 
processes = 5 
 
socket = /run/uwsgi/%(project).sock 
chown-socket = %(uid):www-data 
chmod-socket = 660 
vacuum = true 

/etc/nginx/sites-enabled/boofeh

server { 
    listen 80; 
    server_name iranpersianland.com www.iranpersianland.com; 
    access_log  /var/log/nginx/boofeh.access.log; 
    error_log /var/log/nginx/boofeh.error.log debug; 
    client_max_body_size 100M; 
    location = /favicon.ico { access_log off; log_not_found off; } 
    location /static/base/ { 
        root /home/boofeh/sitebuilder; 
        expires -1; 
        sendfile off; 
    } 
 
    location /static/ { 
        root /home/boofeh; 
    } 
 
 
    location / { 
        include         uwsgi_params; 
        uwsgi_pass      unix:/run/uwsgi/boofeh.sock; 
    } 
} 

我使用这个教程:How To Serve Django Applications with uWSGI and Nginx on Ubuntu 16.04

我在我的项目中使用这些版本: 1.Django==2.0.4 2.djangorestframework==3.8.2

有什么问题? 谁能帮帮我?

boofeh.error.log:

2018/08/30 07:01:00 [debug] 25677#25677: epoll add event: fd:8 op:1 ev:00002001 
2018/08/30 07:01:04 [debug] 25677#25677: accept on 0.0.0.0:80, ready: 0 
2018/08/30 07:01:04 [debug] 25677#25677: posix_memalign: 000055715F5AAAF0:512 @16 
2018/08/30 07:01:04 [debug] 25677#25677: *1 accept: 31.58.254.183:13730 fd:3 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer add: 3: 60000:1535626924708 
2018/08/30 07:01:04 [debug] 25677#25677: *1 reusable connection: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 epoll add event: fd:3 op:1 ev:80002001 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http wait request handler 
2018/08/30 07:01:04 [debug] 25677#25677: *1 malloc: 000055715F5AAD00:1024 
2018/08/30 07:01:04 [debug] 25677#25677: *1 recv: fd:3 564 of 1024 
2018/08/30 07:01:04 [debug] 25677#25677: *1 reusable connection: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 posix_memalign: 000055715F5B58C0:4096 @16 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http process request line 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http request line: "GET / HTTP/1.1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http uri: "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http args: "" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http exten: "" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 posix_memalign: 000055715F5AC890:4096 @16 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http process request header line 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Upgrade-Insecure-Requests: 1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Accept-Encoding: gzip, deflate" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Accept-Language: en-US,en;q=0.9,fa;q=0.8" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Cookie: trx_addons_is_retina=0; csrftoken=NOWkrU12LMJehQSGPCifvuxet6GlS6lu3O31e0UbUIMzHZtRo6H2B19Wc6cVOLHQ" 
2018/08/30 07:01:04 [info] 25677#25677: *1 client sent invalid header line: "AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0.3" while reading client request headers, client: 31.58.254.183, server: iranpersianland.com, request: "GET / HTTP/1.1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Host: 195.201.62.104" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Cache-Control: max-age=0" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header: "Connection: keep-alive" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http header done 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer del: 3: 1535626924708 
2018/08/30 07:01:04 [debug] 25677#25677: *1 generic phase: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 rewrite phase: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 test location: "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 using configuration "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http cl:-1 max:104857600 
2018/08/30 07:01:04 [debug] 25677#25677: *1 rewrite phase: 3 
2018/08/30 07:01:04 [debug] 25677#25677: *1 post rewrite phase: 4 
2018/08/30 07:01:04 [debug] 25677#25677: *1 generic phase: 5 
2018/08/30 07:01:04 [debug] 25677#25677: *1 generic phase: 6 
2018/08/30 07:01:04 [debug] 25677#25677: *1 generic phase: 7 
2018/08/30 07:01:04 [debug] 25677#25677: *1 access phase: 8 
2018/08/30 07:01:04 [debug] 25677#25677: *1 access phase: 9 
2018/08/30 07:01:04 [debug] 25677#25677: *1 access phase: 10 
2018/08/30 07:01:04 [debug] 25677#25677: *1 post access phase: 11 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http init upstream, client timer: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 epoll add event: fd:3 op:3 ev:80002005 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "QUERY_STRING" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "QUERY_STRING: " 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "REQUEST_METHOD" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "GET" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "REQUEST_METHOD: GET" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "CONTENT_TYPE" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "CONTENT_TYPE: " 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "CONTENT_LENGTH" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "CONTENT_LENGTH: " 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "REQUEST_URI" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "REQUEST_URI: /" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "PATH_INFO" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "PATH_INFO: /" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "DOCUMENT_ROOT" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "/usr/share/nginx/html" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "DOCUMENT_ROOT: /usr/share/nginx/html" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "SERVER_PROTOCOL" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "HTTP/1.1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "SERVER_PROTOCOL: HTTP/1.1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "REQUEST_SCHEME" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "http" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "REQUEST_SCHEME: http" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "REMOTE_ADDR" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "31.58.254.183" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "REMOTE_ADDR: 31.58.254.183" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "REMOTE_PORT" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "13730" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "REMOTE_PORT: 13730" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "SERVER_PORT" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "80" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "SERVER_PORT: 80" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script copy: "SERVER_NAME" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http script var: "iranpersianland.com" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "SERVER_NAME: iranpersianland.com" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_UPGRADE_INSECURE_REQUESTS: 1" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_ACCEPT_ENCODING: gzip, deflate" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.9,fa;q=0.8" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_COOKIE: trx_addons_is_retina=0; csrftoken=NOWkrU12LMJehQSGPCifvuxet6GlS6lu3O31e0UbUIMzHZtRo6H2B19Wc6cVOLHQ" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_HOST: 195.201.62.104" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_CACHE_CONTROL: max-age=0" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 uwsgi param: "HTTP_CONNECTION: keep-alive" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http cleanup add: 000055715F5B6828 
2018/08/30 07:01:04 [debug] 25677#25677: *1 get rr peer, try: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 stream socket 12 
2018/08/30 07:01:04 [debug] 25677#25677: *1 epoll add connection: fd:12 ev:80002005 
2018/08/30 07:01:04 [debug] 25677#25677: *1 connect to unix:/run/uwsgi/boofeh.sock, fd:12 #2 
2018/08/30 07:01:04 [debug] 25677#25677: *1 connected 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream connect: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 posix_memalign: 000055715F58BF70:128 @16 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream send request 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream send request body 
2018/08/30 07:01:04 [debug] 25677#25677: *1 chain writer buf fl:0 s:834 
2018/08/30 07:01:04 [debug] 25677#25677: *1 chain writer in: 000055715F5B6860 
2018/08/30 07:01:04 [debug] 25677#25677: *1 writev: 834 of 834 
2018/08/30 07:01:04 [debug] 25677#25677: *1 chain writer out: 0000000000000000 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer add: 12: 60000:1535626924709 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http finalize request: -4, "/?" a:1, c:2 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http request count:2 blk:0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http run request: "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream check client, write event:1, "/" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream recv(): -1 (11: Resource temporarily unavailable) 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream request: "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream process header 
2018/08/30 07:01:04 [debug] 25677#25677: *1 malloc: 000055715F59D8C0:4096 
2018/08/30 07:01:04 [debug] 25677#25677: *1 recv: fd:12 104 of 4096 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http uwsgi status 500 "500 Internal Server Error" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http uwsgi header: "Connection: close" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http uwsgi header: "Content-Type: text/plain" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http uwsgi header done 
2018/08/30 07:01:04 [debug] 25677#25677: *1 xslt filter header 
2018/08/30 07:01:04 [debug] 25677#25677: *1 HTTP/1.1 500 Internal Server Error 
Server: nginx/1.10.3 (Ubuntu) 
Date: Thu, 30 Aug 2018 11:01:04 GMT 
Content-Type: text/plain 
Transfer-Encoding: chunked 
Connection: keep-alive 
 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write new buf t:1 f:0 000055715F5AD5D0, pos 000055715F5AD5D0, size: 184 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http write filter: l:0 f:0 s:184 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http cacheable: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream process upstream 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe read upstream: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe preread: 21 
2018/08/30 07:01:04 [debug] 25677#25677: *1 readv: 1, last:3992 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe recv chain: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe buf free s:0 t:1 f:0 000055715F59D8C0, pos 000055715F59D913, size: 21 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe length: -1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 input buf #0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe write downstream: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe write downstream flush in 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http output filter "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http copy filter: "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 image filter 
2018/08/30 07:01:04 [debug] 25677#25677: *1 xslt filter body 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http postpone filter "/?" 000055715F5AD7A8 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http chunk: 21 
2018/08/30 07:01:04 [debug] 25677#25677: *1 posix_memalign: 000055715F590520:4096 @16 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write old buf t:1 f:0 000055715F5AD5D0, pos 000055715F5AD5D0, size: 184 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write new buf t:1 f:0 000055715F5905A0, pos 000055715F5905A0, size: 4 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write new buf t:1 f:0 000055715F59D8C0, pos 000055715F59D913, size: 21 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write new buf t:0 f:0 0000000000000000, pos 000055715D8DE81E, size: 2 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http write filter: l:0 f:0 s:211 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http copy filter: 0 "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 pipe write downstream done 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer: 12, old: 1535626924709, new: 1535626924710 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream exit: 0000000000000000 
2018/08/30 07:01:04 [debug] 25677#25677: *1 finalize http upstream request: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 finalize http uwsgi request 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free rr peer 1 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 close http upstream connection: 12 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F58BF70, unused: 48 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer del: 12: 1535626924709 
2018/08/30 07:01:04 [debug] 25677#25677: *1 reusable connection: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http upstream temp fd: -1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http output filter "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http copy filter: "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 image filter 
2018/08/30 07:01:04 [debug] 25677#25677: *1 xslt filter body 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http postpone filter "/?" 00007FFD35BAF520 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http chunk: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write old buf t:1 f:0 000055715F5AD5D0, pos 000055715F5AD5D0, size: 184 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write old buf t:1 f:0 000055715F5905A0, pos 000055715F5905A0, size: 4 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write old buf t:1 f:0 000055715F59D8C0, pos 000055715F59D913, size: 21 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write old buf t:0 f:0 0000000000000000, pos 000055715D8DE81E, size: 2 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 write new buf t:0 f:0 0000000000000000, pos 000055715D8DE81B, size: 5 file: 0, size: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http write filter: l:1 f:0 s:216 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http write filter limit 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 writev: 216 of 216 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http write filter 0000000000000000 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http copy filter: 0 "/?" 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http finalize request: 0, "/?" a:1, c:1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 set http keepalive handler 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http close request 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http log handler 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F59D8C0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F5B58C0, unused: 12 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F5AC890, unused: 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F590520, unused: 3390 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F5AAD00 
2018/08/30 07:01:04 [debug] 25677#25677: *1 hc free: 0000000000000000 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 hc busy: 0000000000000000 0 
2018/08/30 07:01:04 [debug] 25677#25677: *1 tcp_nodelay 
2018/08/30 07:01:04 [debug] 25677#25677: *1 reusable connection: 1 
2018/08/30 07:01:04 [debug] 25677#25677: *1 event timer add: 3: 65000:1535626929710 
2018/08/30 07:01:04 [debug] 25677#25677: *1 post event 000055715F5C1450 
2018/08/30 07:01:04 [debug] 25677#25677: *1 delete posted event 000055715F5C1450 
2018/08/30 07:01:04 [debug] 25677#25677: *1 http keepalive handler 
2018/08/30 07:01:04 [debug] 25677#25677: *1 malloc: 000055715F5AAD00:1024 
2018/08/30 07:01:04 [debug] 25677#25677: *1 recv: fd:3 -1 of 1024 
2018/08/30 07:01:04 [debug] 25677#25677: *1 recv() not ready (11: Resource temporarily unavailable) 
2018/08/30 07:01:04 [debug] 25677#25677: *1 free: 000055715F5AAD00 
2018/08/30 07:02:09 [debug] 25677#25677: *1 event timer del: 3: 1535626929710 
2018/08/30 07:02:09 [debug] 25677#25677: *1 http keepalive handler 
2018/08/30 07:02:09 [debug] 25677#25677: *1 close http connection: 3 
2018/08/30 07:02:09 [debug] 25677#25677: *1 reusable connection: 0 
2018/08/30 07:02:09 [debug] 25677#25677: *1 free: 0000000000000000 
2018/08/30 07:02:09 [debug] 25677#25677: *1 free: 000055715F5AAAF0, unused: 112 

uwsgi.error.log:

*** uWSGI is running in multiple interpreter mode *** 
spawned uWSGI master process (pid: 2794) 
spawned uWSGI worker 1 (pid: 2796, cores: 1) 
spawned uWSGI worker 2 (pid: 2797, cores: 1) 
spawned uWSGI worker 3 (pid: 2798, cores: 1) 
spawned uWSGI worker 4 (pid: 2799, cores: 1) 
spawned uWSGI worker 5 (pid: 2800, cores: 1) 
--- no python application found, check your startup logs for errors --- 
[pid: 2796|app: -1|req: -1/1] 162.158.89.228 () {56 vars in 1084 bytes} [Fri Aug 31 21:16:35 2018] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0) 
announcing my loyalty to the Emperor... 

请您参考如下方法:

我发现了我的问题。这导致我在服务器上有两个环境,而 uwsgi 设置是在另一个没有安装 rest 框架的环境中设置的。 谢谢大家