简体   繁体   中英

Using iRedMail with a django site on the same server

I am trying to create a small django site and use iRedMail for e-mail. I installed iRedMail first, and ensured that it worked. I could go to both www.domain.com/iredadmin and www.domain.com/mail and have it work perfectly. My next step was to install my django site and configure Apache. Unfortunately, this caused my django site to try and handle /mail/ and /iredadmin/. I've been fidgeting with the config for a few hours now and have no idea what to do. Here are the settings:

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>

The django website displays fine, although I have been getting internal server errors.

You are trying to use both mod_wsgi and mod_python to handle the Django site at the same time, with mod_python overriding mod_wsgi. Choose one of the other. Since mod_python is no longer developed or supported and support for it in Django deprecated, probably not a good option to keep using it.

The next thing which is wrong is:

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

Remove the trailing slashes:

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

Even then it will still not work, because when using mod_python you have to tell mod_python not to handle those paths.

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

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

A further problem you may have is that /admin is usually used for the Django admin interface and you are overriding that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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