已解决:在vps中部署django

在虚拟专用服务器 (VPS) 上部署 Django 的主要问题是它可能会占用大量资源。 这是因为 Django 需要大量的内存和 CPU 资源才能正常运行。

I have a problem with my Django project. I'm trying to deploy it on my VPS, but I can't get it to work.
This is the error that I get:
<code>    Traceback (most recent call last):
  File "/home/myuser/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/myuser/.local/lib/python3.6/site-packages/django/utils/deprecation.py", line 93, in __call__
    response = self.get_response(request)
  File "/home/myuser/.local/lib//python3.6//site-packages//django//core//handlers//base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/myuser/.local//python3.6//site-packages///django///core///handlers///base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  ...

  File "/usr / local / lib / python3 . 6 / site - packages / django / core / management / base . py " , line 371 , in execute     output = self . handle ( * args , ** options )   File "./manage . py" , line 72 , in handle     execute_from_command _line ( sys . argv )   File "/usr // local // lib // python3 . 6 // site - packages /// django /// core /// management /// __init__ . py " , line 363 , in execute _from _command _line utility . execute ()   File "/usr // local // lib // python3 . 6 // site - packages /// django /// core /// management /// __init__ . py " , line 355 , in execute self . fetch _command ( subcommand ). run _from _argv ( self . argv )   File "/usr // local // lib // python3 . 6 // site - packages /// django /// core /// management /** init**" , line 206 , in fetch _command klass = load _command class ( appname ) KeyError : 'demo' [ 04 : 19 : 10 web1 : 1805 ] [ WSGI ] Error getting traceback from worker process : &lt; type 'exceptions' &gt;: 'module' object has no attribute 'wsgi' [ 04 : 19 : 10 web1 : 1805 ] [ WSGI ] Traceback from worker process &lt; type 'exceptions' &gt;: 'module' object has no attribute 'wsgi' [ 04 : 19 : 10 web1 : 1805 ] [ WSGI ] Traceback from worker process &lt; type 'exceptions' &gt;: 'module' object has no attribute 'wsgi'. wsgi application 1 init failed ; not restarting ...</code>

该代码试图在 VPS 上部署 Django 项目,但出现错误。 错误是“wsgi”应用程序未正确初始化。

什么是 VPS

VPS 是虚拟专用服务器。 它是一种服务器,允许您运行自己的网站或应用程序。

Django 的最佳 VPS

这个问题没有确定的答案,因为它取决于 Django 项目的具体需求。 但是,Django VPS 提供商的一些流行选择包括 Heroku、Amazon Web Services (AWS) 和 Google Cloud Platform (GCP)。 每个都有自己的优点和缺点,因此仔细考虑哪个最适合特定项目很重要。

选择 Django VPS 提供商时要考虑的一些关键因素包括:

1. 操作系统:大多数 Django VPS 提供商都提供一系列不同的操作系统,因此选择一个符合您项目要求的操作系统非常重要。 例如,GCP 同时支持 Linux 和 Windows,而 AWS 同时提供 Windows 和 Linux 选项。

2. CPU 和内存:Django VPS 应该有足够的 CPU 能力和内存来处理您的项目的需求。 例如,GCP 提供比 AWS 更强大的 CPU 和更大的内存池,而 AWS 提供功率更低的 CPU,但内存分配更慷慨。

3. 安全:选择具有强大安全措施的供应商很重要。 例如,GCP 提供强大的安全功能,例如加密数据存储和通过双因素身份验证 (2FA) 进行的用户身份验证。 AWS 也提供了一些安全功能,但它们可能并不适合所有项目。

相关文章:

发表评论