Apache + WSGI:地址已被使用:make_sock:无法绑定到地址

问题描述:

当我尝试启动 Apache2 时收到以下消息:

I get the following message when I try to start Apache2:

* Restarting web server apache2                                                  
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:2080
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

uwsgi 正在监听那个端口:

uwsgi is listening on that port:

sudo netstat -ltnp | grep ':2080'
tcp        0      0 0.0.0.0:2080            0.0.0.0:*               LISTEN  884/uwsgi

之前我手动安装过 wsgi

Before that I installed wsgi manually

sudo apt-get install libapache2-mod-wsgi

因为我在尝试启动 Apache 时收到此消息:

because I got this message when I tried to start Apache:

Syntax error on line 25 of /etc/apache2/sites-enabled/graphite:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
   ...fail!

终止进程不起作用,因为它会自动重新启动.我可以用命令禁用它

Killing the process does not work because it gets automatically restarted. I can disable it with the command

sudo a2dismod wsgi

但后来我再次收到无效命令'WSGIDaemonProcess'消息.

But then I get the "Invalid command 'WSGIDaemonProcess' message once again.

apache error.log 不包含任何相关信息.

The apache error.log does not contain any information on that.

知道什么可以解决这个问题吗?因为现在我有点陷入僵局.

Any idea what could solve this? Because right now I'm kind of in a deadlock.

如果你得到:

Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed.

那么这意味着你还没有在 Apache 中启用 mod_wsgi 模块,所以它没有被加载.

then it means you haven't enabled the mod_wsgi module in Apache and so it isn't loaded.

那或者您正在运行一个古老的 Apache 1.3 版本,尽管这极不可能,因为您现在甚至无法获得如此旧的 Apache 版本的 mod_wsgi 二进制包.

That or you are running an ancient Apache 1.3 version, although that is highly unlikely as don't think you can even get mod_wsgi binary packages for such an old Apache version now.

关于端口使用,Apache和uWSGI显然不能使用同一个,所以需要设置不同的端口.

As to port usage, you obviously can't have Apache and uWSGI using the same one, so you need to set them up with different ports.