Django的在Apache wtih的mod_wsgi(Linux环境) - 403禁止 [英] 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:
故宫
您没有权限访问/在此服务器上。
在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
.
αS据我而言,我所做的一切都是正确的(我实现了该方法的两倍),这很容易被一个操作系统错误(我运行薄荷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.
我做了一些研究,但这些都不(<一个href=\"http://stackoverflow.com/questions/19445686/ubuntu-server-apache-2-4-6-client-denied-by-server-configuration-php-fpm\">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
文件:
So here is mysite.conf
file:
<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
文件:
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的在Apache wtih的mod_wsgi(Linux环境) - 403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!