使用教程设置Django和apache是行不通的

2024-10-02 00:21:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用django站点here中的教程,用现有的django项目来设置apache。我的操作系统是Ubuntu,一切都安装好了(django apache2 libapache2 mod wsgi)

我的配置文件

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>

创建conf文件后,我运行a2ensite Ubuntu命令来启用该站点。在

将WSGIPythonPath放在VirtualHost中会导致apacheconfigtest失败 directory中的Files inside指令(如示例中所述)给了我同样的失败

如果我去www.myrhombus.com网站我收到一条谷歌chrome找不到指定地址的消息。在

我做错什么了?互联网上的每个教程都使用旧的文件.wsgi虽然现在Django为您创建了这个文件,但是它是一个扩展名为.py的python文件。我如何为apache提供django服务?如果我想在我自己的服务器上生产,你会把django代码放在哪里,模板文件放在哪里?在

编辑:我只得到/页的索引。在权限方面,我和mysites的位置有什么关系吗?你能给我一个django站点apacheconf文件的工作示例吗?在


Tags: 文件djangocomwsgihome站点ubuntuapache
1条回答
网友
1楼 · 发布于 2024-10-02 00:21:46

我使用django1.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 admin@key.com
    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-在

^{pr2}$

我想这对你有帮助。在

相关问题 更多 >

    热门问题