在IIS服务器windows 2016中安装django proyect时出现问题

问题描述 投票:0回答:1

我需要帮助解决以下问题:

raise RuntimeError('No Apache installation can be found. Set the '
      RuntimeError: No Apache installation can be found. Set the MOD_WSGI_APACHE_ROOTDIR environment to its location.

当我尝试在服务器上运行该文件时,就会出现这种情况。这是 web.config 文件的内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
        <add name="Proyectoqr" 
        path="*" 
        verb="*" 
        modules="FastCgiModule" 
        scriptProcessor="C:\Python35\python.exe|C:\Python35\Lib\site-packages\wfastcgi.py" 
        resourceType="Unspecified"
        requireAccess="Script"/>
    </handlers>
     </system.webServer>

    <appSettings>
    <add key="PYTHONPATH" value="C:\inetpub\wwwroot\proyectoqr"/>
    <add key="WSGI_HANDLER" value="proyectoqr.wsgi.application"/>
    <add key="DJANGO_SETTINGS_MODULE" value="proyectoqr.settings"/>
    <add key="APPLICATION" value="get_wsgi_application()"/>
    </appSettings>
</configuration> 

这是项目的设置文件

import os
from pathlib import Path
from telnetlib import LOGOUT
from django.urls import reverse_lazy

BASE_DIR = Path(__file__).resolve().parent.parent
DEBUG = False
ALLOWED_HOSTS = ['10.100.10.133', 'localhost', "127.0.0.1:8000", '127.0.0.1' ]

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    'import_export',

    "apps.equipo",
    "apps.usuariof",
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.RemoteUserMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'proyectoqr.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ["templates"],
        
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.RemoteUserBackend',
]

WSGI_APPLICATION = 'proyectoqr.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'es-mx'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True

STATIC_URL = ''

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

STATIC_URL = '/static/'
STATIC_ROOT=os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media')

LOGIN_URL = 'login'
LOGOUT_URL = 'logout'

这是处理程序映射中的配置 enter image description here

这是FastCGI中的配置 enter image description here

如果您需要了解其他配置请评论

尝试通过终端安装 mod_wsgi 时出错

enter image description here

尝试通过终端安装 mod_wsgi 时出现新错误 enter image description here

django iis web-deployment windows-server-2016
1个回答
0
投票

如果您恢复与 FastCGI 相关的所有更改并使用 HttpPlatformHandler 干净地启动,您将看到体验是多么流畅,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\python.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Local\Programs\Python\Python310\python.exe" arguments=".\mysite\manage.py runserver %HTTP_PLATFORM_PORT%">
        </httpPlatform>
    </system.webServer>
</configuration>

Python/Django 仍然负责处理包括静态文件在内的所有事务,而 IIS/HttpPlatformHandler 只是传递请求。

更多详细信息可以从我的博客文章找到。

© www.soinside.com 2019 - 2024. All rights reserved.