未创建uwsgi套接字文件 [英] uwsgi socket file not created

查看:128
本文介绍了未创建uwsgi套接字文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用uwsgi和nginx设置服务器.这是我的uwsgi ini文件(以及vassals中的符号链接):

I am having trouble setting up server using uwsgi and nginx. This is my uwsgi ini file (and symlink in vassals):

# ebook_uwsgi.ini file
[uwsgi]
#emperor = /etc/uwsgi/vassals
#plugins        = python #if uwsgi installed with pip, dont have to use this line
# Django-related settings
# the base directory (full path)
chdir           = /var/www/django/ebook/ebook/wsgi/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         = /var/uwsgi/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

这是我的nginx conf文件:

and this is my nginx conf file:

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    server unix:///var/uwsgi/ebook.sock; # for a file socket
    #server 127.0.0.1:8000; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name IP; #www.domain.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 / {
        include     /var/www/django/ebook/ebook/uwsgi_params; # the uwsgi_params file you installed
    }
}

当我以用户(lucas03)的身份运行uwsgi时

When I run uwsgi as my user(lucas03)

uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data

这是输出:

*** Starting uWSGI 2.0.10 (64bit) on [Tue May 12 20:43:19 2015] ***
compiled with version: 4.7.2 on 14 April 2015 16:47:40
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
pcre jit disabled
detected number of CPU cores: 8
current working directory: /var
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 2062113
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from ebook_uwsgi.ini
*** Starting uWSGI 2.0.10 (64bit) on [Tue May 12 20:43:19 2015] ***
compiled with version: 4.7.2 on 14 April 2015 16:47:40
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
pcre jit disabled
detected number of CPU cores: 8
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
chdir() to /var/www/django/ebook/ebook/wsgi/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 /var/uwsgi/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 0xea41a0
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 ***
virtualenv is active
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xea41a0 pid: 6291 (default app)
mountpoint  already configured. skip.
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 6291)
Tue May 12 20:43:19 2015 - [emperor] vassal ebook_uwsgi.ini has been spawned
spawned uWSGI worker 1 (pid: 6292, cores: 1)
spawned uWSGI worker 2 (pid: 6293, cores: 1)
Tue May 12 20:43:19 2015 - [emperor] vassal ebook_uwsgi.ini is ready to accept requests
spawned uWSGI worker 3 (pid: 6294, cores: 1)
spawned uWSGI worker 4 (pid: 6295, cores: 1)
spawned uWSGI worker 5 (pid: 6296, cores: 1)
spawned uWSGI worker 6 (pid: 6297, cores: 1)
spawned uWSGI worker 7 (pid: 6298, cores: 1)
spawned uWSGI worker 8 (pid: 6299, cores: 1)
spawned uWSGI worker 9 (pid: 6300, cores: 1)
spawned uWSGI worker 10 (pid: 6301, cores: 1)

ebook.sock已创建:

ebook.sock is created:

drwxrwxr-x  2 www-data www-data  3 máj 12 20:43 .
drwxr-xr-x 13 root     root     15 apr 14 16:29 ..
srw-rw-r--  1 lucas03  lucas03   0 máj 12 20:43 ebook.sock

但是我得到了502 Bad Gateway.因此,我将ebook.sock的所有者更改为www-data sudo chown www-data:www-data ebook.sock,我的网站已正确加载.好吧,我认为那太好了.现在,我只需要运行uwsgi,以便它可以以用户www-data的身份创建ebook.sock.
因此,我设置了 uwsgi在启动时启动,我编辑了/etc/rc.local.

but I get 502 Bad Gateway. So I change owner of ebook.sock to www-data sudo chown www-data:www-data ebook.sock, my website is loaded correctly. Well, I thought it was great. Now I just need to run uwsgi so that it can create ebook.sock as user www-data.
So I set uwsgi to start on startup, I edited /etc/rc.local.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
exit 0

但是,当我重新启动服务器后,尽管uwsgi运行了,但根本没有创建文件ebook.sock. (我可以在ps aux | grep uwsgi中看到它).因此,我认为它的运行方式与以root用户身份运行该文件的方式相同或相似.
所以我运行文件/etc/rc.local,这是输出:

However, after I restart server, file ebook.sock is not created at all, although uwsgi runs. (I can see it in ps aux | grep uwsgi). So I thought that it is run same or similar way as if I run that file as root.
So I run file /etc/rc.local and this is output:

*** Starting uWSGI 2.0.10 (64bit) on [Tue May 12 20:57:35 2015] ***
compiled with version: 4.7.2 on 14 April 2015 16:47:40
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
pcre jit disabled
detected number of CPU cores: 8
current working directory: /var/uwsgi
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 2062113
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***

由于输出较短,我想未加载/etc/uwsgi/vassals中的配置文件,并且在运行皇室附庸时存在一些问题.
有人知道为什么吗?

Since output is shorter, I guess config files in /etc/uwsgi/vassals are not loaded and there is some problem running emperor vassals.
Anybody have any idea why?

推荐答案

/var/www/django/的所有者更改为www-data使其起作用.

Changing the owner of /var/www/django/ to www-data made it work.

具体来说,问题出在文件/etc/nginx/uwsgi_params的所有权上.

Specifically the problem was with ownership of the file /etc/nginx/uwsgi_params.

这篇关于未创建uwsgi套接字文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆