ImportError:没有名为mysite.wsgi-uwsgi的模块和nginx设置



我在设置生产服务器时遇到问题。到目前为止,我的应用程序一直在使用openshift.com。但现在我创建了一个数据库很大的应用程序,1GB很快就不够了。所以我将我的应用程序电子书移动到我的vps服务器。我试着用袜子选项和帝王模式来遵循这个文档
我安装了virtualenv、uwsgi和nginx。如果我用./manage.py runserver ip:port运行我的应用程序,我可以在ip:port上查看我的网站
由于openshift,我有一些奇怪的路径:
virtualenv路径/var/www/django/ebook
openshift项目路径/var/www/django/ebook/ebook
项目路径/var/www/django/ebook/ebook/wsgi/ebook,其中我有manage.py和controller(其中有settings.py文件的应用程序)

然而,使用uwsgi运行它是不起作用的。发生导入错误:
ImportError: No module named controller.wsgi
完整的uwsgi输出:

[uWSGI] getting INI configuration from ebook_uwsgi.ini
*** Starting uWSGI 2.0.10 (64bit) on [Mon Apr 13 00:36:54 2015] ***
compiled with version: 4.7.2 on 11 April 2015 12:59:22
os: Linux-2.6.32-042stab104.1 #1 SMP Thu Jan 29 12:58:41 MSK 2015
nodename: zoltan
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /var/www/django/ebook/ebook
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /var/www/django/ebook/ebook/
your processes number limit is 2062113
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/ebook.sock fd 3
Python version: 2.7.3 (default, Mar 13 2014, 11:26:58)  [GCC 4.7.2]
Set PythonHome to /var/www/django/ebook
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x13eb280
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 800448 bytes (781 KB) for 10 cores
*** Operational MODE: preforking ***
ImportError: No module named controller.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
virtualenv is active
Traceback (most recent call last):
File "/var/www/django/ebook/ebook/wsgi/ebook/controller/wsgi.py", line 40, in <module>
application = get_wsgi_application()
File "/var/www/django/ebook/local/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/var/www/django/ebook/local/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/__init__.py", line 20, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/var/www/django/ebook/local/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/var/www/django/ebook/local/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/var/www/django/ebook/local/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/conf/__init__.py", line 98, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'controller.settings # set an environment variable' (Is it on sys.path? Is there an import error in the settings file?): No module named settings # set an environment variable
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 7864)
spawned uWSGI worker 1 (pid: 7865, cores: 1)
spawned uWSGI worker 2 (pid: 7866, cores: 1)
spawned uWSGI worker 3 (pid: 7867, cores: 1)
spawned uWSGI worker 4 (pid: 7868, cores: 1)
spawned uWSGI worker 5 (pid: 7869, cores: 1)
spawned uWSGI worker 6 (pid: 7870, cores: 1)
spawned uWSGI worker 7 (pid: 7871, cores: 1)
spawned uWSGI worker 8 (pid: 7872, cores: 1)
spawned uWSGI worker 9 (pid: 7873, cores: 1)
spawned uWSGI worker 10 (pid: 7874, cores: 1)

这是我运行uwsgi时使用的ebook_uwsgi.ini:

# ebook_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir           = /var/www/django/ebook/ebook/
# Django's wsgi file
module          = controller.wsgi:application
# the virtualenv (full path)
home            = /var/www/django/ebook
# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket          = /tmp/ebook.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 664
uid             = www-data
gid             = www-data
# clear environment on exit
vacuum          = true
no-site         = True
wsgi-file       = /var/www/django/ebook/ebook/wsgi/ebook/controller/wsgi.py
env             = DJANGO_SETTINGS_MODULE=controller.settings # set an environment variable

和ebook_nginx.conf:#mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/ebook.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen      8001;
# the domain name it will serve for
server_name MY_IP_ADDRESS #.bookdownloading.com; # substitute your machine's IP address or FQDN
charset     utf-8;
# max upload size
client_max_body_size 75M;   # adjust to taste
# Django media
location /media  {
alias /var/www/django/ebook/ebook/data;  # your Django project's media files - amend as required
}
location /static {
alias /var/www/django/ebook/ebook/wsgi/static/; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass  unix:///tmp/ebook.sock;
include     /var/www/django/ebook/ebook/uwsgi_params; # the uwsgi_params file you installed
}
}

这是我在控制器应用程序中的wsgi.py文件:

import sys
activate_this = '/var/www/django/ebook/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import os
if hasattr(sys, 'real_prefix'):
print "virtualenv is active"
sys.path.append("/var/www/django/ebook/lib/python2.7/site-packages/")
sys.path.append("/var/www/django/ebook/ebook/wsgi")
sys.path.insert(0, "/var/www/django/ebook/ebook/wsgi/ebook")
sys.path.append("/var/www/django/ebook/ebook/wsgi/ebook/controller")
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "digrin.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "controller.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

我在sys.path中有很多附加/插入命令,因为我不确定哪一个足够。我想插入一个就足够了
我正在运行apache for php,这就是我使用8001端口的原因。应用程序给我ImportError。知道吗,我缺了什么?

Openshift结构让我有点困惑。chdir应该是:
chdir = /var/www/django/ebook/ebook/wsgi/ebook/

最新更新