apache 上的多个 django 项目 [更新]

Multiple django projects on apache [UPDATE]

经过帮助,我得出了一个proj.conf这样的:

<VirtualHost *:80>
    WSGIScriptAlias /f_app /home/4rsenal/f_proj/f_proj/wsgi.py

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustumLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static/ /home/4rsenal/f_proj/static
    <Directory /home/4rsenal/f_proj/static>
            Require all granted
    </Directory>

    <Directory /home/4rsenal/f_proj/f_proj>
            <Files wsgi.py>
                    Requier all granted
            </Files>
    </Directory>
    WSGIProcessGroup f_proj
    WSGIDaemonProcess f_proj python-home=/home/4rsenal/f_proj/f_projenv python-path=/home/4rsenal/f_proj   
</VirtualHost>

<VirtualHost *:80>
    WSGIScriptAlias /m_app /home/4rsenal/m_proj/m_proj/wsgi.py

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustumLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static/ /home/4rsenal/m_proj/static
    <Directory /home/4rsenal/m_proj/static>
            Require all granted
    </Directory>

    <Directory /home/4rsenal/m_proj/m_proj>
            <Files wsgi.py>
                    Requier all granted
            </Files>
    </Directory>
    WSGIProcessGroup m_proj
    WSGIDaemonProcess m_proj python-home=/home/4rsenal/m_proj/m_projenv python-path=/home/4rsenal/m_proj
</VirtualHost>

使用新别名,如果我输入 http://[MYIPADDRESS]/f_app/f_app/ I'm good to go with that site, but if I type in http://[MYIPADDRESS]/m_app/m_app/,我会收到“未找到”错误。为什么一个别名有效而​​另一个无效? (一旦我让这些都起作用,我可以稍后修复这些看起来很愚蠢的网址)。

如果您的配置准确,问题的基础是您有两个 VirtualHost 定义,但都没有 ServerName。这意味着无法应用基于名称的主机名匹配,因此它将始终使用第一个 VirtualHost.

如果您希望它们都在同一个主机名下,那么配置应该都在一个 VirtualHost.

博客 post:

中解释了此类问题以及与 运行 同时使用多个 Django 应用程序相关的其他问题