您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Django,Virtualenv,nginx + uwsgi导入模块wsgi错误

Django,Virtualenv,nginx + uwsgi导入模块wsgi错误

我更新了wsgi.py使其看起来像这样:

import os
import sys
import site

site.addsitedir(os.path.join('/home/ubuntu/ve','project/lib/python2.6/site-packages'))
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
sys.path.append(os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../../'))
sys.path.append(os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../'))

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.configs.staging.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我的uwsgi.conf文件现在看起来像这样:

# file: /etc/init/uwsgi.conf
description "uWSGI starter"

start on (local-filesystems and runlevel [2345])
stop on runlevel [016]

respawn

# home - is the path to our virtualenv directory
# pythonpath - the path to our django application
# module - the wsgi handler python script

exec /home/ubuntu/ve/project/bin/uwsgi \
--uid ubuntu \
--pythonpath /home/ubuntu/django-projects/project/project/configs/staging \
-H /home/ubuntu/ve/project \
--socket /tmp/uwsgi.sock \
--chmod-socket 644 \
--module wsgi \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /home/ubuntu/logs/project/uwsgi.log

我的Nginx网站可用文件如下所示:

# file: /etc/Nginx/sites-available/yourdomain.com
# Nginx configuration for project.maumercado.com

server {
        listen 80;
        charset utf-8;
        server_name project.maumercado.com;
        access_log /home/ubuntu/logs/project/Nginx/access.log;
        error_log /home/ubuntu/logs/project/Nginx/error.log;

        location ^~ /cache/ {
                root /home/ubuntu/django-projects/project/project/media;
                expires max;
        }

        location / {
                uwsgi_pass unix:/tmp/uwsgi.sock;
                include /etc/Nginx/uwsgi_params;
        }
}

现在它的工作非常完美,我在样式方面遇到了一些问题,因为在css文件中使用了像ñ这样的奇怪字符。

现在,我想知道当需要使用uwsgi在同一服务器上运行更多项目时该怎么办?

Go 2022/1/1 18:48:03 有356人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶