问题标签 [django-deployment]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
933 浏览

django - 服务器重新启动后如何重新启动 Django 应用程序?

我已经使用 gunicorn + nginx + postgres 部署了 Django 应用程序。我正在使用 digitalocean ubuntu 服务器。有时每月一次会自动重新启动,因此应用程序出现故障。如何自动重启应用程序?我的启动脚本:

服务器自动重新启动后,我会手动重新运行此脚本。

0 投票
2 回答
7543 浏览

django - Deploying Django Channels: how to keep Daphne running after exiting shell on web server

As practice, I'm trying to deploy Andrew Godwin's multichat example with Django Channels 2.1.1 on DigitalOcean Ubuntu 16.04.4. However, I don't know how to exit the Ubuntu server without Channels' Daphne server stopping.

Right now, almost my entire familiarity with deployment comes from this tutorial, and that's how I've deployed the site. But according to Channels' documentation, I have to run one of these three in production to start Daphne:

  • daphne myproject.asgi:application
  • daphne -p 8001 myproject.asgi:application
  • daphne -b 0.0.0.0 -p 8001 myproject.asgi:application

So, in addition to following the DigitalOcean tutorial, I ran these also. The third one worked for me and the site ran well. However, if I exit shell on Ubuntu, Daphne stops too.

The tutorial has gunicorn access a sock file (--bind unix:/home/sammy/myproject/myproject.sock), and in my research so far I've seen on a few sites published before 2018 that somehow somewhere a daphne.sock file is generated. So, I guess Channels deploys similarly? But I haven't seen any details about how this is done.

How do I deploy the multichat example so I can exit the Ubuntu web server without Daphne stopping?

Update 6 May 2018, 8pm CET:

I tried kagronick's solution below and created a systemd file at /etc/systemd/system/daphne_seb.service:

I did systemctl daemon-reload and systemctl start daphne_seb.service and it ran for a couple of seconds. Then, systemctl status daphne_seb.service said Unknown command: 'daphne'.

I tried restarting it. Then I rebooted the OS. Now status says:

I checked the filepaths. They're correct. I also tried adding Environment=DJANGO_SETTINGS_MODULE=multichat.settings, which I saw here. But that didn't help either.

Update 6 May 2018, 10pm CET:

Then, I read here that only 5 restarts are allowed within a 10-second period. So I removed Restart=on-failure to start the service myself.

This brought me back to Unknown command: 'daphne'. This solution suggested to me that I shouldn't be pointing to Python but to Daphne in my virtualenv, so I changed it: ExecStart=/home/seb/env_seb/bin/daphne. I also removed /home/seb/seb/manage.py based on the same solution. This gave me a new problem:

I check my multichat.asgi:application and it's in the right place. So I can't figure out why it says error: unrecognized arguments: multichat.asgi:application.

0 投票
1 回答
3149 浏览

python - 在 apache 上使用 pipenv 部署 django 应用程序

Django 2.0使用pipenvvirtualenv创建了一个 python Web 应用程序

现在,我必须将它托管在 apache 服务器上。我已经安装libapache2-mod-wsgi-py3python-setuptools在服务器中。

我的应用程序的结构就像

要放置的应用程序的路径

我已将所有文件移至目录并Pipfile通过在目录中运行安装了所有依赖项

这已经创建了一个 virtualenv 并安装了所有必需的模块和给定的pipenv --venv路径

我的VirtualHost配置看起来像

VirtualInclude 包含

但是在访问http://app.application.com它时Internal server error,生成的日志文件包含

编辑 2

app/wsgi.py 修改wsgi.py文件激活virtual environment

另外,ls -l /path_to_pipenv_venv/bin

在此处输入图像描述

0 投票
0 回答
174 浏览

django - Python Django Ubuntu Server 16.04 aws 内部服务器错误

您好,我正在尝试将我的产品组合部署到 Ubuntu Server 16.04,但我不断收到内部服务器错误。

为了完成我所做的事情,我创建了实例并将 HTTP 和 HTTPS 安全设置更改为任何地方。

之后我启动了实例然后运行这些命令

我编辑了 settings.py

然后运行,

其次是,

我在哪里添加

然后是 gunicorn 重启

最后,

添加

创建链接

然后重新启动

编辑**

我更改了以下代码以完全匹配我所做的。

0 投票
1 回答
51 浏览

django - 如何为不同的客户运行单个 django 项目

我使用 开发了一个名为“SANET”的 Web 应用程序djangogunicornnginx为一个名为customerA并授予他们访问权限的客户使用customerA.mydomain.com.

现在,一位新客户customerB订购了专用版本。

这是我认为我可以做的(我希望它们都在特定的服务器上):

  1. 从项目复制并customerB.mydomain.com像完全不同的项目一样部署它
  2. 根据请求的域找到一种方法来更改项目数据库配置

如果您能指导我选择其中一个选项或为我提供更好的方法,我们将不胜感激。

0 投票
0 回答
78 浏览

django - Debian Nginx 监听但不工作

我在 Debian 上为 Django 设置 Nginx 时遇到了很多麻烦。

我可能尝试了我可以在互联网上找到的每个 nginx django conf 文件,但没有一个有效,我想我看不到树木的福雷斯特......

所以我正在运行 Django 2.0.4 和 daphne 2.1.1。

对于达芙妮,我使用这个命令:

这是我的 Nginx Conf 文件,我添加了一个指向 google 的重定向,所以我实际上可以看到它正在运行:

跑步netstat -nlp | grep 80

另外,/etc/init.d/nginx status说 Nginx 正在运行。

Sites-available 和 sites-enabled 都是链接的。

我错过了什么?有人有想法或需要更多信息吗?

0 投票
0 回答
494 浏览

python - django 或 gunicorn 无法读取 linux 环境变量

在 Ubuntu 16.04 服务器中,我在 python shell 中运行以下命令:

输出是:

这意味着环境变量已正确设置。但是当我运行sudo systemctl status gunicorn检查 gunicorn 状态时,os.environ它不能正常工作。这是gunicorn运行django时的输出:

DJANGO_DB_NAME, DJANGO_DB_USERNAME, DJANGO_DB_PASSWORD, DJANGO_SECRET_KEY未找到以下键。也没有显示其他变量。
谁知道是什么问题??

0 投票
1 回答
494 浏览

amazon-ec2 - 如何使用mysql在aws ec2上部署python3 django2网站

我以前从未托管过任何网站,这可能就是为什么这项任务对我来说如此艰巨的原因。我搜索了各种代码进行部署,但无法托管我的网站。

我为我的网站使用了带有 mysql 数据库的 python 3.6.4 和 django 2.0.2。如果我从头开始按照我的要求进行部署,那将是一个很大的帮助。

提前致谢!

0 投票
3 回答
879 浏览

django - 无法在数字海洋上上传媒体文件 django

我最近在数字海洋上部署了一个 django 应用程序。在我尝试创建一个包含图像的对象之前,一切都很好。我收到一条错误消息,提示服务器错误 (500)。

这是我尝试做的事情:

这是我的 settings.py 代码:

不幸的是,这并没有成功。
如果您知道我的问题的答案,请帮助我。

更新
我发现我的代码存在问题:当我将调试设置为 True 时,我收到一条错误消息
errno 13: Permission denied.

但是,我不知道如何解决这个问题。

如果可以,请你帮助我。

0 投票
1 回答
297 浏览

django - FastCGI 进程经常失败,使用 IIS 在 windows 2012 服务器上部署 Django 应用程序时出错

在此处输入图像描述我正在尝试使用 IIS 在 Windows 2012 服务器上部署 Django 应用程序。我的 web.config 文件:

收到“HTTP 错误 500 - 内部服务器错误”。请查找附件以查看错误。使用 Django 版本:2 和 IIS 版本:8.5 我按照以下链接进行链接: http ://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html 请帮帮我,我需要使用 IIS 服务器在 Windows 上部署 Django 应用程序。