繁体   English   中英

将iRedMail与同一服务器上的Django站点一起使用

[英]Using iRedMail with a django site on the same server

我正在尝试创建一个小型django网站,并使用iRedMail收发电子邮件。 我首先安装了iRedMail,并确保它可以正常工作。 我可以同时访问www.domain.com/iredadmin和www.domain.com/mail并使其正常运行。 下一步是安装django网站并配置Apache。 不幸的是,这导致我的django网站尝试处理/ mail /和/ iredadmin /。 我已经对配置感到烦恼了几个小时,却不知道该怎么做。 设置如下:

apache2.conf:

# Defaults...

WSGIPythonPath /path/to/website.com/website

sites-enabled / website.com:

<VirtualHost *:80>
    ServerName website.in
    ServerAlias www.website.in
    ErrorLog ${APACHE_LOG_DIR}/error.log

    Alias /static /path/to/website.com/website/static
    Alias /media /path/to/website.com/website/media
    Alias /mail /usr/share/apache2/roundcubemail/
    Alias /admin /usr/share/apache2/iredadmin/


    <Directory /usr/share/apache2/roundcubemail/>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /path/to/website.com/website/website.wsgi

    <Location "/">
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            SetEnv DJANGO_SETTINGS_MODULE website.settings
            PythonDebug Off
            PythonPath "['/path/to/website.com/website/']+sys.path"
    </Location>

    <Directory /path/to/website.com/website>
        <Files wsgi.py>
            Order deny,allow
            Allow from all
        </Files>
    </Directory>

    <Directory /path/to/website.com/website/static>
        Order allow,deny
        Allow from all
    </Directory>

    <Location /static/>
        SetHandler None
    </Location>

    <Directory /path/to/website.com/website/media>
        Order allow,deny
        Allow from all
    </Directory>

    <Location /media/>
        SetHandler None
    </Location>

</VirtualHost>

django网站显示正常,尽管我一直在收到内部服务器错误。

您正在尝试同时使用mod_wsgi和mod_python来处理Django站点,而mod_python会覆盖mod_wsgi。 选择另一个。 由于不再开发或不支持mod_python,并且不推荐在Django中使用它,因此继续使用它可能不是一个好选择。

接下来的错误是:

Alias /mail /usr/share/apache2/roundcubemail/
Alias /admin /usr/share/apache2/iredadmin/

删除斜杠:

Alias /mail /usr/share/apache2/roundcubemail
Alias /admin /usr/share/apache2/iredadmin

即使这样,它仍然无法正常工作,因为使用mod_python时,您必须告诉mod_python不要处理这些路径。

<Location /mail/>
    SetHandler None
</Location>

<Location /admin/>
    SetHandler None
</Location>

您可能遇到的另一个问题是/ admin通常用于Django管理界面,而您将其覆盖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM