
지난 6시간 동안 머리를 세게 부딪혔는데 아무것도 효과가 없는 것 같습니다.
nginx와 uwsgi를 통해 Django를 호스팅하려고 합니다. 나의 이해와 연구를 바탕으로 nginx.conf 및 uwsgi.ini 파일을 구성했습니다.
nginx.conf
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:/tmp/abc.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 2048M; # adjust to taste
# Django media
location /media {
alias /<path_to>/media; # your Django project's media files - amend as required
}
location /static {
alias /<path_to>/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
include /<path_to>/uwsgi_params; # the uwsgi_params file you installed
uwsgi_param REMOTE_USER $remote_user;
uwsgi_param DATE_GMT $date_gmt;
uwsgi_param DATE_LOCAL $date_local;
uwsgi_param AUTH_TYPE Basic;
uwsgi_read_timeout 600s;
uwsgi_pass django;
}
}
uwsgi.ini
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = <path_to>/site
# Django's wsgi file
module = pjgweb.wsgi:application
# the virtualenv (full path)
home = /<path_to>/ENV
# process-related settings
# gid
gid = www-data
# uid
uid = www-data
# master
master = true
# maximum number of worker processes
processes = 6
# maximum number of threads for each worker process
threads = 5
# the socket (use the full path to be safe
socket = /tmp/abc.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
thread_lock = true
python_thread = true
# set the DJANGO MODULE SETTINGS
env = DJANGO_SETTINGS_MODULE=pjintegweb.settings_production
# Log to
logto = /<path_to>/uwsgi-app.log
# Statistics
stats = :9191
stats-http = true
또한 nginx.conf 및 uwsgi.ini에 대한 심볼릭 링크도 만들었습니다.
systemd에 대한 Emperor.uwsgi.service 파일을 구성했습니다.
[Unit] Description=uWSGI Emperor service After=syslog.target [Service] ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data Restart=always KillSignal=SIGQUIT Type=notify StandardError=syslog NotifyAccess=all [Install] WantedBy=multi-user.target
nginx 로그 파일을 확인하면 다음이 표시됩니다.
: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:05:37 [crit] 1949#1949: *1 connect() to unix:/run/uwsgi/abc.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:05:37 [crit] 1949#1949: *1 connect() to unix:/run/uwsgi/abc.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:39:04 [alert] 2890#2890: *1 open socket #21 left in connection 3
2021/06/09 16:39:04 [alert] 2890#2890: *2 open socket #22 left in connection 4
2021/06/09 16:39:04 [alert] 2890#2890: aborting
uwsgi 로그
bind(): No such file or directory [core/socket.c line 230]
*** Starting uWSGI 2.0.19.1 (64bit) on [Wed Jun 9 18:48:43 2021] ***
compiled with version: 7.5.0 on 02 June 2021 07:22:38
os: Linux-5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020
machine: x86_64
clock source: unix
detected number of CPU cores: 12
current working directory: /<path_to>
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /<path_to>
your processes number limit is 127942
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/abc.sock fd 3
Python version: 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
PEP 405 virtualenv detected: /<path_to>/ENV
Set PythonHome to /<path_to>/ENV
Python main interpreter initialized at 0x55cc047f50c0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 802648 bytes (783 KB) for 30 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x55cc047f50c0 pid: 2828 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2828)
spawned uWSGI worker 1 (pid: 2833, cores: 5)
spawned uWSGI worker 2 (pid: 2834, cores: 5)
spawned uWSGI worker 3 (pid: 2835, cores: 5)
spawned uWSGI worker 4 (pid: 2840, cores: 5)
spawned uWSGI worker 5 (pid: 2845, cores: 5)
spawned uWSGI worker 6 (pid: 2850, cores: 5)
*** Stats server enabled on :9191 fd: 21 ***
SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
worker 4 buried after 1 seconds
worker 5 buried after 1 seconds
worker 6 buried after 1 seconds
goodbye to uWSGI.
VACUUM: unix socket /tmp/abc.sock removed.
다음 명령을 실행하면 오류가 표시되지 않지만 명령줄로 돌아가지 않습니다. 왜 그런지 모르겠어
uwsgi --ini uwsgi.ini [uWSGI] /path_to/uwsgi.ini에서 INI 구성 가져오기
그것은 영원히 거기에 있습니다. 인터넷에서 많은 게시물을 보았지만 그 중 어느 것도 나에게 도움이 되지 않는 것 같습니다. 도와주세요. 감사해요.
새 로그:
--- no python application found, check your startup logs for errors ---
[pid: 9219|app: -1|req: -1/1] x.x.x.x () {38 vars in 707 bytes} [Thu Jun 10 09:26:20 2021] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)