代码之家  ›  专栏  ›  技术社区  ›  Tsuna

(未找到可调用或导入错误)未加载应用程序。以全动态模式运行

  •  0
  • Tsuna  · 技术社区  · 7 年前

    这件事困扰了我好几个小时,我不知道发生了什么。当我尝试只通过ip访问该站点时。我明白了 internal server error

    重新启动时,我会收到此错误日志 daemon and uwsgi

    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
    Python version: 2.7.12 (default, Dec  4 2017, 14:50:18)  [GCC 5.4.0 20160609]
    Set PythonHome to /root/wxr/wxr
    *** Python threads support is disabled. You can enable it with --enable-threads ***
    Python main interpreter initialized at 0xe0db20
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
    your server socket listen backlog is limited to 100 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 437520 bytes (427 KB) for 5 cores
    *** Operational MODE: preforking ***
    Traceback (most recent call last):
      File "./main/wsgi.py", line 10, in <module>
        import os
    ImportError: No module named os
    unable to load app 0 (mountpoint='') (callable not found or import error)
    Traceback (most recent call last):
      File "/root/wxr/wxr/main/wsgi.py", line 10, in <module>
        import os
    ImportError: No module named os
    unable to load app 0 (mountpoint='') (callable not found or import error)
    *** no app loaded. going in full dynamic mode ***
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
    *** uWSGI is running in multiple interpreter mode ***
    

    ubuntu 16.04 root 用户设置,而不是有其他用户

    我把它作为我的服务器块 site-available

    server {
            listen 80 default_server;
            listen [::]:80 default_server;
    
            # root /var/www/html;
    
            # Add index.php to the list if you are using PHP
            # index index.html index.htm index.nginx-debian.html;
    
            server_name _;
    
            location = /favicon.ico { access_log off; log_not_found off; }
    
            location /media  {
                    alias /root/wxr/wxr/mediafiles;  # your Django project's media files - amend as required
            }
    
    
    
            location /static/ {
                    alias /root/wxr/wxr/static;
            }
    
            location / {
                include /root/wxr/wxr/uwsgi_params;
                uwsgi_pass unix:/tmp/uwsgi/wxr.sock;
                uwsgi_param Host $host;
                uwsgi_param X-Real-IP $remote_addr;
                uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
                uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
    
            }
    }
    

    /etc/uwsgi/sites/wxr.ini

    [uwsgi]
    project = wxr
    base =/root
    
    
    #chdir = %(base)/%(project)/%(project)
    #home = %(base)/%(project)/%(project)
    wsgi-file = /root/wxr/wxr/main/wsgi.py
    chdir = /root/wxr/wxr
    home = /root/wxr/wxr
    
    module = main.wsgi:application
    
    master = true
    processes = 5
    
    socket = /tmp/uwsgi/%(project).sock
    chmod-socket = 666
    vacuum = true
    enable-threads = true
    no-site = true
    
    req-logger = file:/tmp/reqlog
    logger = file:/tmp/errlog
    

    我的 /etc/systemd/system/uwsgi.service

    [Unit]
    Description=uWSGI Emperor service
    
    [Service]
    ExecStartPre=/bin/bash -c 'mkdir -p /tmp/uwsgi; chown root:www-data /tmp/uwsgi'
    ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
    Restart=always
    KillSignal=SIGQUIT
    Type=notify
    NotifyAccess=all
    
    [Install]
    WantedBy=multi-user.target
    
    0 回复  |  直到 7 年前
    推荐文章