正确配置httpd。django站点配置

时间:2022-03-31 07:30:20

So I'm trying to deploy my django project using apache 2.2 and mod_wsgi. I've gotten to the point of configuring my httpd.conf file for apache but think I might be doing something wrong since I keep getting "403: You don't have permission to access / on this server." when trying to access my site.正确配置httpd。django站点配置

因此,我试图使用apache 2.2和mod_wsgi部署我的django项目。我已经开始配置我的httpd。当我试图访问我的站点时,我不断地收到“403:你没有权限访问/在这个服务器上”,但是我认为我可能做错了什么。

This is what my project structure looks like:

这就是我的项目结构:

"C:\wamp2.2\ums" 
myapp/
    pm_app/
        __init__.py
        settings.py
        urls.py
        wsgi.py

    ums/
        static/..
        templates/..
        __init__.py
        admin.py
        models.py
        views.py
    manage.py
    requirements.txt

pm_app contains the wsgi.py file and ums is the folder with the site

pm_app包含wsgi。py文件和ums是包含站点的文件夹

wsgi.py:

wsgi.py:

import os, sys

sys.path.append('C:/wamp2.2/ums')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pm_app.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

httpd.conf:

httpd . conf。

WSGIPythonPath "C:/wamp2.2/ums"
WSGIScriptAlias / "C:/wamp2.2/ums/pm_app"

<Directory "C:/wamp2.2/ums/ums">
<Files wsgi.py>
    Order deny,allow
    Allow from all
</Files>
</Directory>

did I get my pathing wrong? or am I missing something. Am I also accessing the site correctly via localhost or should it be localhost/ums?

我走错路了吗?还是我漏掉了什么。我是否也正确地通过localhost访问站点,还是应该是localhost/ums?

Should also note this is my first time deploying a site so bare with me

还需要注意的是,这是我第一次部署这么简单的站点吗

1 个解决方案

#1


1  

so after scratching my head I figured I'd look at the apache error logs which were far more helpful. Seems my Directory and Files tags had the wrong values.

所以在绞尽脑汁之后,我想我应该看看apache错误日志,它更有帮助。似乎我的目录和文件标签有错误的值。

This is what works for me:

这对我很有效:

WSGIScriptAlias / "C:/wamp2.2/ums/pm_app/wsgi.py"
WSGIPythonPath "C:/wamp2.2/ums/env/Lib/site-packages";"C:/wamp2.2/ums/pm_app"

<Directory "C:/wamp2.2/ums/pm_app">
    <Files "wsgi.py">
      Order deny,allow
      Allow from all
    </Files>
</Directory>

#1


1  

so after scratching my head I figured I'd look at the apache error logs which were far more helpful. Seems my Directory and Files tags had the wrong values.

所以在绞尽脑汁之后,我想我应该看看apache错误日志,它更有帮助。似乎我的目录和文件标签有错误的值。

This is what works for me:

这对我很有效:

WSGIScriptAlias / "C:/wamp2.2/ums/pm_app/wsgi.py"
WSGIPythonPath "C:/wamp2.2/ums/env/Lib/site-packages";"C:/wamp2.2/ums/pm_app"

<Directory "C:/wamp2.2/ums/pm_app">
    <Files "wsgi.py">
      Order deny,allow
      Allow from all
    </Files>
</Directory>