试图configurationubuntu + nginx + uwsgi + django 新贵脚本/etc/init/uwsgi.conf description "uWSGI application server in Emperor mode" start on runlevel [2345] stop on runlevel [!2345] setuid voxa setgid www-data exec /usr/local/bin/uwsgi –emperor /etc/uwsgi/sites uwsgiconfiguration [uwsgi] project = project base = /home/user chdir = %(base)/%(project) home = home/user/Env/project_env module = %(project).wsgi:application master = true processes = 5 socket […]
我试图得到django-mobile (使用不同的模板名称空间,取决于设备types)当varnish和nginx时。 我想我已经想通了,但是用我目前的设置,似乎nginx只使用查询参数设置cookie而不是头,所以事情只有在一个额外的重新加载后才会改变。 这是如此复杂的原因是,清漆可以caching给定url的页面的两个版本(完整和移动)。 清漆configuration sub vcl_hash { hash_data(req.http.X-Flavour); hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } return (hash); } nginxconfiguration location / { # default flavour set $flavour "full"; # autodetect mobile flavour if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") { set $flavour "mobile"; } # get previously set flavour from […]
启动uwsgi时有问题: unable to find "application" callable in file dashboard/wsgi.py unable to load app 0 (mountpoint='') (callable not found or import error) uwsgi.ini: [uwsgi] socket = /tmp/dashboard.sock chdir = /srv/http/depo-dashboard/ wsgi-file = dashboard/wsgi.py callable = app processes = 4 threads = 2 chmod-socket = 666 wsgi.py: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dashboard.settings") application = […]
我似乎是Django-Celery-RabbitMQ项目部署的最后一步。 通过systemd运行芹菜,httpd和rabbitmq-server服务,当我在Django中触发任务时,我看到消息Received task: smartalec.tasks.match_loadfile_task 在哪里smartalec是我的应用程序,并match_loadfile_task是我的任务,该项目被称为tcida_api。 但30秒左右之后,会有一个巨大的堆栈跟踪,如下所示(完整的debugging日志,下面有例外)。 [2016-09-09 15:34:20,040: ERROR/MainProcess] Task smartalec.tasks.match_loadfile_task[740dc792-7410-4418-aa44-dd9c56b63b04] raised unexpected: DatabaseError(' <cx_Oracle._Error object at 0x3a3ed50>',) 谷歌search“Django甲骨文Celery数据库错误”得到一些关于在单个连接共享线程的查询,但我不知道是否适用于我,因为我在我的数据库configurationproject.settings中“threaded = TRUE”。 从命令行运行芹菜时,我也一样。 sudo /opt/tcida/virtualenv/smartalec/bin/celery -A my_django_project worker -l info 我没有安装django芹菜,Django可以使数据库查询没有问题,通过shell和网页,configuration在我的本地机器上使用django的开发服务器工作。 什么可以导致或解决这个exception? 全芹菜DEBUG日志,uncluding完整的堆栈跟踪。 [amartin@ip-10-50-7-148 tcida_api]$ sudo /opt/tcida/virtualenv/smartalec/bin/celery -A tcida_api worker –concurrency 1 -l debug /opt/tcida/virtualenv/smartalec/lib/python2.7/site-packages/celery/platforms.py:812: RuntimeWarning: You are running the worker with superuser privileges, which is […]
现在我已经使用apache2和mod-wsgi在我的服务器上部署了一个python2 django应用程序。 现在我想部署另一个,但是这是用python3编写的。 我的问题是,mod-wsgi被编译为python2。 我有什么替代scheme来部署? 我可以使用mod-uwsgi for python3进行另一个部署。 PD:我也在使用virtualenvs。 谢谢!
我想避免使用django和nginx不一致的错误页面。 如果一个静态文件没有find默认的nginx错误页面,而不是django的。 我认为这会导致性能不佳,将每个失败的请求redirect到gunicorn服务器,最终导致django错误页面。 我在哪里可以find默认的django错误页面,以及如何让nginx使用它们?
当通过mod_wsgi提供Django应用程序时,我注意到了一个奇怪的错误。 在我的文档根目录中,我使用LocationMatch指令将/admin目录限制为127.0.0.1。 我也有/admin URLConf挂载/在Django应用程序,这是Django的自动生成的pipe理界面的标准path。 该应用程序本身位于/apppath下,使用WSGIScriptAlias指令进行configuration。 现在,Apache以某种方式将每个请求处理为/app/admin并将其子path定向为应用程序和文档根目录。 我得到Django的pipe理显示,但是error.log包含这样一行: [Tue Feb 14 01:25:35.538501 2017] [authz_core:error] [pid 29235] [client 32.135.203.150:36412] AH01630: client denied by server configuration: /var/www/html/admin/ 除了两件事之外,这几乎不是问题: 我不得不closuresfail2ban, 我不能在pipe理员上传文件,我怀疑这是为什么,因为这个错误出现在我每次尝试(接收500作为响应)。 这是通过重命名我的html目录或Django的pipe理应用程序来解决的,但我真的很想find正确的解决scheme,让我有两个。 Debian中的Apacheconfiguration被分割成多个文件,但我相信相关的部分如下: <VirtualHost *:80> ServerAdmin webmaster@localhost SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Include conf-available/default.conf DocumentRoot /var/www/html <LocationMatch ^/admin> Require ip 127.0.0.1 ::1 […]
我有Django运行在Nginx之后。 其中一个域提供图像文件,如果存在这样的文件,则从本地文件系统上的caching中提取;如果不存在,则用django脚本提供。 要从机器人隐藏真实的文件名我有时想洗牌文件中的字符。 在这种情况下,url有一个“/ x /”前缀。 这是我在nginxconfiguration的尝试: server { listen 80; server_name mydomain.com; client_max_body_size 5M; access_log /var/log/nginx/mydomain.access.log; location /robots.txt { root /srv/www/mydomain.com; } rewrite ^/x/(.)(.)(.)(.)(.)(.)(.*)$ $5$2$6$3$1$4.jpg last; location ~* ^.+\.(jpeg|gif|png|jpg|webp) { root /srv/imagecache; try_files /$uri @aws; } location @aws { fastcgi_pass unix:/srv/django/myapp/myapp.sock; fastcgi_param SERVER_NAME $server_name; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param […]
我正在build立一个ec2服务器,用ngnix和gunicorn来运行一个django项目。 服务器正在运行Amazon Linux。 当我从命令行运行启动gunicorn命令,它启动服务器,但是当我尝试从pipe理员运行它,我得到以下错误: supervisor: couldn't chdir to /home/ec2-user/virtualenvs/wakeup-site/django-site: EACCES supervisor: child process was not spawned 当我以sudo身份运行supervisor或者以我自己的用户身份运行时会发生这种情况 目录权限:/ home / ec2-user / virtualenvs / wakeup-site / django-site drwxrwxrwx 15 ec2-user ec2-user 4096 Mar 6 08:21 django-site 相关的Supervisor.conf文件: [program:wakeup] command=./start_gunicorn.bash directory="/home/ec2-user/virtualenvs/wakeup-site/django-site" user=ec2-user autostart=true autorestart=true stdout_logfile=/home/ec2-user/virtualenvs/wakeup-site/django-site/logs/supervisorconf.log stderr_logfile=/home/ec2-user/virtualenvs/wakeup-site/django-site/logs/gunicorn_stderr.log start_gunicorn.bash: #!/bin/bash # Starts the Gunicorn server set -e # […]
我安装了一个amazon实例(中等ubuntu)与运行postgres服务器。 我从我的个人电脑连接到该服务器,虽然它通常工作,我经常会得到以下错误(随机): OperationalError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. 我的连接是好的,实例似乎是好的(它没有崩溃或任何东西,我可以立即重新连接,它的工作完美)。 我看postgres的主要日志,并看到这样的线路匹配断开连接: 2017-04-03 07:26:24.073 UTC [28918] testadmin@test_db FATAL: connection to client lost 哪些不是很有帮助。 我怎样才能解决这个问题? 任何人都有一个想法,为什么这可能发生在亚马逊实例? 它是一个简单的介质实例没有负载平衡器,没有弹性IP(我通过实例的公共DNS连接)。 谢谢!