按照此链接发布的教程,我正在尝试运行一个与gunicorn&nginx绑定的django项目。
How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04
项目文件夹上的tree命令提供此输出。
当我使用# python manage.py runserver
发布项目时,可以查看其内容。但是,当我尝试使用unicorn和以下命令将其绑定时,会显示以下错误。
# gunicorn --bind 0.0.0.0:8000 DjangoWebsiteSample.eccomerceProject.wsgi.py
[2019-05-10 05:25:11 +0000] [1912] [INFO] Starting gunicorn 19.7.1
[2019-05-10 05:25:11 +0000] [1912] [INFO] Listening at: http://0.0.0.0:8000 (1912)
[2019-05-10 05:25:11 +0000] [1912] [INFO] Using worker: sync
[2019-05-10 05:25:11 +0000] [1916] [INFO] Booting worker with pid: 1916
[2019-05-10 05:25:11 +0000] [1916] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 377, in import_app
__import__(module)
ImportError: No module named DjangoWebsiteSample.eccomerceProject.wsgi.py
[2019-05-10 05:25:11 +0000] [1916] [INFO] Worker exiting (pid: 1916)
[2019-05-10 05:25:11 +0000] [1912] [INFO] Shutting down: Master
[2019-05-10 05:25:11 +0000] [1912] [INFO] Reason: Worker failed to boot.
答案 0 :(得分:2)
尝试以下命令:
gunicorn --bind 0.0.0.0:8000 eccomerceProject.wsgi