2016-06-11 86 views
0

因此,我即将午餐我的第一个Django网站,我目前有一个服务器已被配置为托管PHP网站,我已决定测试一个简单的空项目,以熟悉过程Django网站在Apache与wsgi失败

所以这个服务器的Python版本有点旧(2.6),所以我不能安装最新版本的Django,我安装了1.6,因为它只是一个不重要的测试(即时升级蟒蛇版本时我的网站是准备好午餐)

所以我已经安装Django和这个可怕的

创建了一个新的项目称为测试

,你可以看到使用这个域名

http://novadmin20.com

和阅读的Django文档后(不幸的是他们已经删除DOC 1.6,我不得不使用1.9)和WSGI我已经更新了我的httpd。 CONF这样

<VirtualHost 111.111.111.111:80> 
    ServerName 111.111.111.111 
    DocumentRoot /usr/local/apache/htdocs 
    ServerAdmin [email protected] 
    <IfModule mod_suphp.c> 
     suPHP_UserGroup nobody nobody 
    </IfModule> 

    <Directory /home/sdfds34fre/public_html/testing/testing> 
     <Files wsgi.py> 
      Require all granted 
     </Files> 
    </Directory> 


    WSGIDaemonProcess testing python-path=/home/sdfds34fre/public_html/testing:/usr/lib64/python2.6/site-packages/ 
    WSGIProcessGroup testing 
    WSGIScriptAlias//home/sdfds34fre/public_html/testing/testing/wsgi.py 


</VirtualHost> 

但即使重新启动httpd服务,当我去

http://novadmin20.com/testing/ 

所有我看到的是目录列表,我错过了什么?

这里是我的wsgi.py文件

""" 
WSGI config for testing project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/ 
""" 

import os 
import sys 

sys.path.append(os.path.dirname(os.path.dirname(__file__))) 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testing.settings") 

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

什么Linux发行版是您使用,并且你有root权限?如果你使用的是CentOS 6(Python 2.6),那么安装更新的Python替代版本相当容易,并且可以编译mod_wsgi。我有一步一步的指导,所以如果可以的话,让我知道。 – FlipperPA

+0

@FlipperPA thanx这台服务器是centos 6但是我已经订购了一台新的服务器和centos 7用于这个网站......我不确定python的版本是否会与centos 7一起提供7 – max

+0

CentOS 7附带Python 2.7.5系统Python。我建议不要在系统上运行Django;最好使用virtualenv。祝你好运! – FlipperPA

回答

0

DocumentRoot指令是你的问题的主要根源。 (ref

尝试此配置:

<VirtualHost 111.111.111.111*:80> 
ServerName novadmin20.com 

WSGIDaemonProcess testing python-path=/home/sdfds34fre/public_html/testing:/usr/lib64/python2.6/site-packages/ 
WSGIScriptAlias//home/sdfds34fre/public_html/testing/testing/wsgi.py 

    <Directory /home/sdfds34fre/public_html/testing/testing> 
    <Files wsgi.py> 
     Order deny,allow 
     Require all granted 
     WSGIProcessGroup testing 
    </Files> 
    </Directory> 

</VirtualHost>