簡體   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