2014-05-15 29 views
1

我想使用django网站here中的教程建立apache与现有的django项目。我的操作系统是Ubuntu的,一切安装(Django的的Apache2中的libapache2-MOD-WSGI)设置django和apache使用教程不起作用

我的conf文件

WSGIPythonPath /home/avlahop/development/django/rhombus2/rhombus/ 

<VirtualHost *:80> 
    ServerName myrhobmus.com 
    ServerAlias www.myrhombus.com 
    WSGIScriptAlias//home/avlahop/development/django/rhombus2/rhombus/rhombus/wsgi.py 
</VirtualHost> 

我创造我跑了a2ensite Ubuntu的命令使网站conf文件后。

把WSGIPythonPath内虚拟主机给我一个apache configtest失败 文件内指令内部目录(如示例中所描述的)给了我同样的错误

如果我去www.myrhombus.com我收到了谷歌浏览器找不到指定的地址信息。

我在做什么错? Internet上的每个教程都使用旧的file.wsgi,而现在Django为您创建了这个教程,但它是一个带.py扩展名的python文件。我怎样才能用apache来服务我的django?如果我想在自己的服务器上进行制作,那么您会在哪里放入django代码,以及将模板文件放在哪里?

编辑:我只获得/页的索引。有什么我必须做的mysites位置的权限?你能给我一个django网站apache conf文件的工作示例吗?

+0

你看到的* exact *错误是什么? –

+0

在哪种情况下?重新启动django或尝试访问我的域时。我通过/ etc/hosts(如127.0.0.1 www.myrhombus.com)解决了我对我的放置记录的访问权限,但现在我得到的是一个列表,其中包含目录包含的文件(但不显示任何文件) /头和上次修改的名称大小说明列 – Apostolos

+0

你说你有Apache配置测试失败。这究竟是什么意思? –

回答

0

我使用Django 1.8,并成功部署了我的项目Apache服务器。我遵循像你这样的基本概念,并尽早启用Apache模块。

enable module

你可以在我的项目结构这个问题。 Refer this question to understand project structure

--------------这是我的虚拟主机文件------------------------- ---------

WSGIPythonPath /home/umayanga/Desktop/view_site/serialKey_gen_site:/home/umayanga/Desktop/view_site/serialKey_gen_site/myvenv/lib/python3.4/site$ 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName key.com 
    ServerAlias www.key.com 

    Alias /templates/ /home/umayanga/Desktop/view_site/serialKey_gen_site/templates/ 
    Alias /static/ /home/umayanga/Desktop/view_site/serialKey_gen_site/static/ 


    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/static"> 
      Require all granted 
    </Directory> 

    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/templates"> 
      Require all granted 
    </Directory> 

    WSGIScriptAlias//home/umayanga/Desktop/view_site/serialKey_gen_site/mysite/wsgi.py 

    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/mysite"> 
     Options Indexes FollowSymLinks 
     AllowOverride all 
     Require all granted 
     <Files wsgi.py> 
       Require all granted 
     </Files> 
    </Directory> 

</VirtualHost> 

----------------- wsgi.py -------------- -------------------------

""" 
WSGI config for mysite 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.8/howto/deployment/wsgi/ 
""" 

import os 

from django.core.wsgi import get_wsgi_application 



os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 

application = get_wsgi_application() 

我认为这对你有帮助。