Django on apache wtih mod_wsgi(Linux) - 403 Forbidden [英] Django on apache wtih mod_wsgi (Linux) - 403 Forbidden

查看:128
本文介绍了Django on apache wtih mod_wsgi(Linux) - 403 Forbidden的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我正在关注这个教程。当我尝试通过我的本地服务器访问我的网站时,我得到这个特殊的错误:

Alright, so i am following this tutorial. When i try to access my site through my local server i get this peculiar error:

禁止
你不有权访问/在此服务器上。
Apache / 2.4.6(Ubuntu)服务器在mysite.com端口80

Forbidden You don't have permission to access / on this server. Apache/2.4.6 (Ubuntu) Server at mysite.com Port 80.

Αsfar as i我非常关心我已经做了一切正确的事情(我实现了两次提出的方法),这可能很容易成为一个操作系统错误(我正在运行Mint 16,错误说(Ubuntu)),然而,我没有经验,因此我需要一些帮助。

Αs far as i am concerned i have done everything right (i implemented twice the proposed method) and this could easily be an OS error (i am running Mint 16 and error says (Ubuntu)), however i am not experienced and therefore i need some help.

我做了一些研究,但没有一个( 1 2 )与其他人一样的问题似乎没有回答我的情况。

I did some research but none of these (1,2) questions along with others, does not seem to answer my case.

所以这里是 mysite.conf 文件:

<VirtualHost *:80>
WSGIScriptAlias / /home/nick/Mysite/mysite.wsgi

ServerName mysite.com
Alias /static /var/www/mysite/static/

<Directory /var/www/mysite/>

Options All
AllowOverride All
Require all granted

</Directory>
</VirtualHost>

和我的主机 ip地址被重定向到我的本地主机:

and my hosts file which shows how the ip address is redirected to my local host:

127.0.0.1   localhost
127.0.1.1   nick-HP-Notebook-PC
192.168.1.2 mysite.com
192.168.1.2 mysite2.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

那么你建议问题是什么。这可能只是一个Linux相关的错误?
,如果您需要有关项目或任何内容的其他信息,请通知我。

So what do you suggest the problem is. Could this be simply a Linux related error? and please let me know if you need additional info about the project or anything.

感谢一吨。

更新:

Update:

这是我的 .wsgi file:

import os
import sys
sys.path = ['/var/www/mysite'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

当我重新启动服务器时,我也收到此消息。

I also get this message when i restart the server.

Restarting web server apache2                                                AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message         [ OK ]

也许这有帮助吗? >

Maybe this helps?

推荐答案

如果这是你的配置文件,那么我怀疑你使用的路径是错误的。请先解决这个问题。

If this is exactly your config file then i doubt the path that you're using is wrong. Please fix that first.

将WSGIScriptAlias设置为正确的路径。

Set WSGIScriptAlias this to correct path.

然后,您的WSGI文件必须如下所示:

Then your WSGI file must look something like:

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

这篇关于Django on apache wtih mod_wsgi(Linux) - 403 Forbidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆