无法连接到Apache s上的Django 1.11 web应用

2024-09-28 02:00:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我不是Django的专家。我能够在本地机器上运行应用程序。我想在我们的内部服务器上部署这个应用程序。 我正在使用的版本:Python:2.7、Django 1.11、Apache:2.4 开放端口:9991

当我从任何机器访问端口时,它都不会给我错误。例如。xxx.xx.xxx.xxx:9991显示阿帕奇页面。你知道吗

但是当我把网址添加到应用程序时 xxx.xx.xxx.xxx:9991/WebApp1Url 它会产生错误。 下面是我的配置httpd.conf文件你知道吗

Listen 9991
<VirtualHost *:9991>
Alias /static "C:/xxx/DjangoSite/WebApps/WebApp1/static"
<Directory "C:/xxx/DjangoSite/WebApps/WebApp1/static">
Require all granted
</Directory>

<Directory "C:/xxx/DjangoSite/WebApps/WebApps">
<Files wsgi.py>
 Require all granted
</Files>
</Directory>
</VirtualHost>

下面是我的wsgi.py公司地址:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "WebApps.settings")
application = get_wsgi_application()
from WebApp1.wsgi import WebApp1
application = WebApp1(application)

你知道吗设置.py包含:

WSGI_APPLICATION = 'WebApps.wsgi.application'

我可以肯定的是wsgi.py公司是正确的。我不知道什么是不对的。有没有人能指出哪一步遗漏了?感谢您的帮助。请原谅上面的任何拼写错误。先谢谢你。你知道吗


Tags: django端口pyimport机器应用程序wsgiapplication
1条回答
网友
1楼 · 发布于 2024-09-28 02:00:27

任何问题的第一站,无论是新用户还是有经验的用户,都应该是Django非常详细、广泛、最新、版本化的文档。甚至还有deploying a Django project with Apache HTTPD的部分。你知道吗

下面引述了一些内容,但概括地说:

  1. 用mod\u wsgi安装Apache HTTPD(在Windows上安装模块可能是最困难的部分,mod\u wsgi docs链接到this guide
  2. 将WSGI指令添加到conf文件

The official mod_wsgi documentation is your source for all the details about how to use mod_wsgi. You’ll probably want to start with the installation and configuration documentation.

Basic configuration

Once you’ve got mod_wsgi installed and activated, edit your Apache server’s httpd.conf file and add the following. If you are using a version of Apache older than 2.4, replace Require all granted with Allow from all and also add the line Order deny,allow above it.

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonHome /path/to/venv
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

相关问题 更多 >

    热门问题