服务器使用Ubuntu 20.4
在 src 文件夹中,我具有所有的Django结构:
diasmart文件夹是项目文件夹(包含settings.py,wsgi.py ...)
settings.py中的我的应用
...
INSTALLED_APPS = [
...
# My apps
'store.apps.StoreConfig',
'orders.apps.OrdersConfig',
'profiles.apps.ProfilesConfig',
]
我的wsgi:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'diasmart.settings')
application = get_wsgi_application()
gunicorn_config.py (主要/gunicorn_config.py):
command = '/root/DiaStore/env/bin/gunicorn'
pythonpath = '/root/usr/bin/python'
bind = '127.0.0.1:8001'
workers = 2
user = 'root'
limit_request_fields = 32000
limit_request_field_size = 0
raw_env = 'DJANGO_SETTINGS_MODULE=src.diasmart.settings'
在 bin 文件夹(主目录/ bin)中,我有“ start_gunicorn.sh ”文件:
(DiaStore为其主文件夹的名称)
#/bin/bash
source /root/DiaStore/env/bin/activate
exec gunicorn -c "/root/DiaStore/gunicorn_config.py" src.diasmart.wsgi
我在终端写信(DiaStore是打开的文件夹):
source ./bin/start_gunicorn.sh
我得到了
:Traceback (most recent call last):
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/root/DiaStore/env/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/root/DiaStore/src/diasmart/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/root/DiaStore/env/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/root/DiaStore/env/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/root/DiaStore/env/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/root/DiaStore/env/lib/python3.8/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'store'
如果我从设置中删除所有应用。INSTALLED_APPS-服务器正常工作。.