2015-05-12 26 views
6

Uwsgi ve nginx kullanarak sunucu kurma konusunda sorun yaşıyorum. Bu (vassalları ve sembolik link) benim uwsgi ini dosyasıdır:uwsgi soket dosyası oluşturulmadı

# 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 

ve bu benim nginx conf dosyasıdır:

benim kullanıcı olarak uwsgi çalıştırmak
# 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 --emperor /etc/uwsgi/vassals --uid www-data --gid www-data 

bu çıktısı şöyledir:

*** 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 oluşturulur:

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 

ama 502 Bad Gateway olsun. Bu yüzden ebook.sock'un sahibini, www. Data sudo chown www-data:www-data ebook.sock'a değiştirdim, web sitem doğru şekilde yüklendi. Şey, harika olduğunu düşündüm. Şimdi uwsgi'yi çalıştırmam gerekiyor, böylece kullanıcı www-data olarak ebook.sock oluşturabilir.
uwsgi to start on startup ayarlıyorum, /etc/rc.local düzenledim. Ben sunucuyu yeniden başlattıktan sonra uwsgi çalışır halde

#!/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 

Ancak, dosya ebook.sock, hiç oluşturulmadı. (ps aux | grep uwsgi'da görebilirim). Bu yüzden, bu dosyayı root olarak çalıştırıyormuş gibi aynı veya benzer şekilde çalıştırıldığını düşündüm.
Yani dosyayı /etc/rc.local çalıştırın ve bu çıktısı: Çıktı kısa olduğundan, /etc/uwsgi/vassals config dosyaları tahmin

*** 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 *** 

yüklenmez ve imparator kölelerine çalışan bazı sorun var.
Neden olduğu hakkında bir fikrin var mı? Herhangi bir cevap veya yorum için şimdiden teşekkür ederiz. www-verilere /var/www/django/ sahibini değiştirme

+0

Hızlı soru, biraz yardıma kendi yaratarak, ne /var/uwsgi/ebook.sock dosya benziyor gerek? –

+2

@DanielGaeta boş, bağlantı için bir soket dosyasıdır. Uwsgi tarafından oluşturulmalıdır. Bunu umursamaman gerek. – Lucas03

cevap

3

çalışması yaptı.

Özellikle sorunlu dosya /etc/nginx/uwsgi_params sahipliği ile oldu.

+2

"root: www-data" için sahiplenmenin değiştirilmesi benim için çalıştı – surfer190

+0

Soketinizi '/ tmp' içine koymaya ve doğru bir yer bulamadığınıza ve – surfer190

+1

@ l/'ama yine de işe yaramadı. "Uwsgi_params" dosyası sorunluydu. – Lucas03

İlgili konular