同一个网站,不同的Django项目,通过不同的u

2024-04-24 22:40:59 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我在:

  • Ubuntu 14.04.3 LTS
  • 阿帕奇/2.4.7
  • 从源代码构建的最新mod-wsgi-3.4
  • Python 3.4 virtualenv
  • 丹戈_1_._86_

我在不同的地点有2个django项目:

  • /主页/管理员/我的项目/
  • /主页/boba/BOB项目/

所以目录在不同的用户下。在

我想为我的项目服务www.example.com网站为波巴服务www.example.com/boba在

我跟随https://gun.io/blog/how-to-install-multiple-django-sites-on-the-same-server/并设置了我的Apache配置文件:

<VirtualHost *:80>
    ServerAdmin a@b.com
    ServerName example.com
    DocumentRoot /var/www/example.com/public_html

    WSGIScriptAlias /boba /home/boba/bobaproject/website/wsgi.py
    WSGIDaemonProcess boba python-path=/home/boba/bobaproject:/home/boba/bobaproject/bbenv/lib/python3.4/site-packages
    WSGIProcessGroup boba
    <Directory /home/boba/bobaproject/website>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static /home/boba/bobaproject/static
    <Directory /home/boba/bobaproject/static>
        Require all granted
    </Directory>

    WSGIScriptAlias / /home/admin/myproject/myproject/wsgi.py
    WSGIDaemonProcess myproject python-path=/home/admin/myproject:/home/admin/myproject/myprojectenv/lib/python3.4/site-packages
    WSGIProcessGroup myproject
    <Directory /home/admin/myproject/myproject>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static /home/admin/myproject/static
    <Directory /home/admin/myproject/static>
        Require all granted
    </Directory>

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

</VirtualHost>

但我在这两方面都只拿到了我的项目www.example.com网站以及www.example.com/boba 如果我删除另一个,两个站点配置都可以工作。 他们在一起就不会。在

对于myproject,我声明wsgi应用程序的顺序似乎是正确的,后面声明的基本url为其提供服务。波巴第一

另外,每个wsgi应用程序都有自己的WSGIProcessGroup。这里会出什么问题?在

我一直在Apache错误日志中看到这一点,不确定是否相关:

^{2}$

谢谢你的帮助。在


Tags: 项目pycomwsgihomeadminexamplemyproject
1条回答
网友
1楼 · 发布于 2024-04-24 22:40:59

在看了这个问题之后,我似乎已经部分地解决了这个问题:Serving 2 django sites with the same code

<VirtualHost *:80>
    ServerAdmin a@b.com
    ServerName example.com       

    WSGIScriptAlias /boba /home/boba/bobaproject/website/wsgi.py
    WSGIDaemonProcess boba python-path=/home/boba/bobaproject:/home/boba/bobaproject/bbenv/lib/python3.4/site-packages
    <Location /boba>
        WSGIProcessGroup boba
    </Location>
    <Directory /home/boba/bobaproject/website>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static /home/boba/bobaproject/static
    <Directory /home/boba/bobaproject/static>
        Require all granted
    </Directory>

    WSGIScriptAlias /myproject /home/admin/myproject/myproject/wsgi.py
    WSGIDaemonProcess myproject python-path=/home/admin/myproject:/home/admin/myproject/myprojectenv/lib/python3.4/site-packages
    <Location /myproject >
        WSGIProcessGroup myproject
    </Location>
    <Directory /home/admin/myproject/myproject>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static /home/admin/myproject/static
    <Directory /home/admin/myproject/static>
        Require all granted
    </Directory>

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

</VirtualHost>

使用WSGIProcessGroup周围的Location标记可以得到www.example.com/boba以及www.example.com/myproject在

但我还是喜欢在基本网址的myproject应用程序example.com网站 我还没弄明白。在

注意:不需要删除DocumentRoot。保留它将导致从基本URL的文档根文件夹提供普通的旧HTML文档www.example.com网站在

相关问题 更多 >