我正在尝试部署一个django项目.我尝试了很多教程,但没有运气.我使用一个新的干净的Ubuntu 11.10.我已经表演了
apt-get install nginx
apt-get install uwsgi
service nginx start
Run Code Online (Sandbox Code Playgroud)
我已经创建了文件夹/deploy/project1
并放在那里manage.py
和其他文件.
我目前/deploy/project1/project1/wsgi.py
包含:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project1.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Run Code Online (Sandbox Code Playgroud)
那么,你能告诉我如何domain.com
正确部署我的django应用程序吗?
我还通过pip和easy_install安装了Django
我应该加入/etc/nginx/sites-enabled/default
.
我目前总是在我的用户正在进行的查询中获得502 ...通常返回872行并在MySQL中运行2.07.然而,它返回了大量信息.(每行包含很多东西).有任何想法吗?
运行Django(tastypie Rest API),Nginx和uWSGI堆栈.
使用NGINX进行服务器配置
# the upstream component nginx needs to connect to
upstream django {
server unix:///srv/www/poka/app/poka/nginx/poka.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on
listen 443;
# the domain name it will serve for
server_name xxxx; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 750M; # adjust to taste
# Finally, send all non-media requests …
Run Code Online (Sandbox Code Playgroud) 我尝试使用此文档配置uWsgi,Django,Nginx:http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
完成配置uwsgi.ini
文件,创建一个软链接/etc/uwsgi/vassals
.
最后一步失败:在系统引导时启动uWSGI.
运行此命令时:
sudo /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
我收到了这个错误:
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 3813
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 …
Run Code Online (Sandbox Code Playgroud) 我有一个Nginx vhost而不是这样配置:
...
location /one {
include uwsgi_params;
uwsgi_pass unix:///.../one.sock;
}
location /two {
include uwsgi_params;
uwsgi_pass unix:///.../two.sock
}
...
Run Code Online (Sandbox Code Playgroud)
这当然是简化的配置
当我请求/one/something
我希望我的Python脚本接收/something
为request_uri
.
我正在使用BottlePy,但希望由Nginx处理,而不是在我的Python代码中处理.
我能做点什么uwsgi_param REQUEST_URI replace($request_uri, '^/one', '')
吗?
编辑
以下是我的Python代码的请求:[pid:30052 | app:0 | req:1/1](){42 vars in 844 bytes} [Tue Aug 21 14:22:07 2012] GET/one/something = >在4 msecs(HTTP/1.1 200)中生成0个字节,在85个字节中生成2个标头(核心0上的0个开关)
所以Python是可以的,但uWSGI不是.
如何解决?
我正在尝试将参数传递给示例wsgi应用程序,:
config_file = sys.argv[1]
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World %s" % config_file]
Run Code Online (Sandbox Code Playgroud)
并运行:
uwsgi --http :9090 --wsgi-file test_uwsgi.py -???? config_file # argument for wsgi script
Run Code Online (Sandbox Code Playgroud)
我能做到的任何聪明方式吗?无法在uwsgi文档中找到它.也许还有另一种方法可以为wsgi应用程序提供一些参数?(环境变量超出范围)
我想我真的搞砸了.在我的django应用程序(生产一个)上,我推了一个重大更新,每当我尝试进入我的域时就会出现"内部服务器错误".我在uwsgi日志中收到错误:
*** Starting uWSGI 2.0.8 (64bit) on [Thu Jan 29 00:36:43 2015] ***
compiled with version: 4.8.2 on 11 December 2014 17:29:38
os: Linux-3.13.0-41-generic #70-Ubuntu SMP Tue Nov 25 14:40:34 UTC 2014
nodename: ip-172-31-9-208
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root …
Run Code Online (Sandbox Code Playgroud) 使用uWSGI和Nginx设置Flask非常困难,即使使用buildout脚本也需要很长时间,并且必须将其记录到稍后要再现的指令中.
如果我不计划服务器上的大负载(它是公开的隐藏),没有uWSGI运行它是否有意义?(Flask可以收听端口.Nginx可以转发请求吗?)
甚至不使用Nginx,只是在端口上运行裸烧瓶应用程序是否有意义?
有人可以帮助知道gunicorn发送信息消息处理信号的原因:绞盘应用程序空闲时。
没有错误,应用程序继续响应,但当它空闲时会显示上面的消息。
除了 WINCH : Gracefully shutdown the worker processes when Gunicorn is daemonized之外,我在 gunicorn 处理信号文档部分找不到更多信息 。
我有一个通过Nginx和uWsgi托管的django应用程序.在某个非常简单的请求中,我得到了GET和POST的不同行为,但情况并非如此.
uWsgi守护程序日志:
[pid: 32454|app: 0|req: 5/17] 127.0.0.1 () {36 vars in 636 bytes} [Tue Oct 19 11:18:36 2010] POST /buy/76d4f520ae82e1dfd35564aed64a885b/a_2/10/ => generated 80 bytes in 3 msecs (HTTP/1.0 440) 1 headers in 76 bytes (0 async switches on async core 0)
[pid: 32455|app: 0|req: 5/18] 127.0.0.1 () {32 vars in 521 bytes} [Tue Oct 19 11:18:50 2010] GET /buy/76d4f520ae82e1dfd35564aed64a885b/a_2/10/ => generated 80 bytes in 3 msecs (HTTP/1.0 440) 1 headers in 76 bytes (0 async switches on async core 0) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在运行Debian 8.1的机器上使用Uwsgi和supervisor部署Django应用程序.
当我重新启动时,sudo systemctl restart supervisor
它无法重启一半的时间.
$ root@host:/# systemctl start supervisor
Job for supervisor.service failed. See 'systemctl status supervisor.service' and 'journalctl -xn' for details.
$ root@host:/# systemctl status supervisor.service
? supervisor.service - LSB: Start/stop supervisor
Loaded: loaded (/etc/init.d/supervisor)
Active: failed (Result: exit-code) since Wed 2015-09-23 11:12:01 UTC; 16s ago
Process: 21505 ExecStop=/etc/init.d/supervisor stop (code=exited, status=0/SUCCESS)
Process: 21511 ExecStart=/etc/init.d/supervisor start (code=exited, status=1/FAILURE)
Sep 23 11:12:01 host supervisor[21511]: Starting supervisor:
Sep 23 11:12:01 host systemd[1]: supervisor.service: control process exited, code=exited …
Run Code Online (Sandbox Code Playgroud)