名称重复以前的 WSGI 守护进程定义

Name duplicates previous WSGI daemon definition

我正在更改站点的域名。有一段时间我想让旧域名和新域名指向站点。我是 运行 一个 Python Django 站点。

我原来的 Apache2 conf 工作正常,基础是:

<VirtualHost *:80>
        ServerAdmin name@gmail.com
        ServerName originalsite.co.uk
        ServerAlias www.originalsite.co.uk
        DocumentRoot /var/www/originalsite
        WSGIDaemonProcess originalsite python-path=/var/www/originalsite:/var/www/originalsite/env/lib/python2.7/site-packages
        WSGIProcessGroup originalsite
        WSGIScriptAlias / /var/www/originalsite/originalsite/wsgi.py
        ...
</VirtualHost>

我设置了一个新的 conf 文件,仅进行了以下更改:

    ServerName newsite.co.uk
    ServerAlias www.newsite.co.uk

我收到以下错误:

Name duplicates previous WSGI daemon definition.

我该如何解决这个问题?感谢您的帮助

更改originalsite名称

不在目录地址中,只是像

这样的名称
WSGIDaemonProcess somethingelse python-path=/var/www/originalsite:/var/www/originalsite/env/‌​lib/python2.7/site-p‌​ackages

WSGIProcessGroup somethingelse

错误的原因是 mod_wsgi 守护进程组的名称在整个 Apache 安装中必须是唯一的。不能在不同的 VirtualHost 定义中使用相同的守护进程组名称。这对于在确定在某些情况下引用的守护进程组时避免冲突是必要的。

我对 Apache2 配置有同样的问题。 就我而言,我在 /etc/apache2/sites-enabled.

中复制了 000-default.conf 文件

首先我在 Linux 中查找 'WSGIDaemon' 字符串:

grep -iRl "WSGIDaemon" ./

第二次分析每一行。我在 /etc/apache2/sites-enabled/000-default-copy.conf 上发现了重复的文件。删除后,检查语法:

sudo apachectl configtest

return'Syntax OK'。我花了 4 个小时......我希望有人用这个 :)

如果您在使用 certbot 命令安装多个“Let's Encrypt Certificates”时遇到此问题,那么这可能是由于 certbot 中的一些错误,如 here 所述.如需快速解决方法,您可以发表评论

WSGIScriptAlias 
WSGIDaemonProcess 
WSGIProcessGroup

到运行certbot命令,然后删除评论。

我通过在 /etc/apache2/sites-enabled/000-default.conf

中评论以下 3 行解决了这个问题
# WSGIDaemonProcess 
# WSGIProcessGroup 
# WSGIScriptAlias

然后 reload/restart Apache2.

我将它们保留在 /etc/apache2/sites-enabled/default-ssl.conf 中,因为它在 HTTP(非 SSL)和 HTTPS(SSL)中重复

虽然给出了正确答案,但是看答案的时候还是一头雾水。因此,这里对在 Apache 上为单个站点启用 HTTP 和 HTTPS 时的特殊情况进行了一些说明。

在您的配置文件之一(比方说 HTTP)中:

# Add this outside of VirtualHost scope to ensure it's global
WSGIDaemonProcess some_name python-path=/var/www/originalsite:/var/www/originalsite/env/‌​lib/python2.7/site-p‌​ackages

...


# Within VirtualHost
WSGIProcessGroup some_name

在另一个配置文件 (HTTPS) 中:

WSGIProcessGroup some_name

就是这样。它所做的是 link 两个配置文件中的同一组。进程名称仅在一个配置文件中定义,这让 Apache 很高兴。