在同一个apache服务器上运行两个带有SSL的django应用程序

时间:2012-10-01 15:44:54

标签: django ssl apache2 mod-wsgi

我在apache2安装了ubuntu lucid,并启用了ssl。现在,我正在使用django个应用程序(简称myapp1mod_wsgi。 我已将/etc/apache2/sites_enabled/ssl文件和/etc/apache2/sites-available/ssl配置如下。

现在我可以使用网址

运行我的应用
https://127.0.0.1/myapp1

我需要在同一台服务器上运行另一个django应用程序(比如myapp2),并且还使用SSL。所以,我应该如何配置它?有人可以帮助我吗?

<VirtualHost *:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/me/dev/python/django/myapp1

        SSLEngine on
        SSLOptions +StrictRequire
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    WSGIScriptAlias /myapp1 /home/me/dev/python/django/myapp1/myapp1.wsgi
    Alias /site_media/ /home/me/dev/python/django/myapp1/media/
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

1 个答案:

答案 0 :(得分:0)

添加:

WSGIScriptAlias /myapp2 /home/me/dev/python/django/myapp2/myapp2.wsgi

如果他们无法共享相同的静态媒体文件,则需要解决任何冲突。也就是说,让每个媒体都在不同的位置,并为每个Django项目配置适当的设置。