apache2错误日志.呼叫'(null)'的'site.addsitedir()'失败,停止 [英] apache2 error log. Call to 'site.addsitedir()' failed for '(null)', stopping

查看:281
本文介绍了apache2错误日志.呼叫'(null)'的'site.addsitedir()'失败,停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Ubuntu中连接Python和Apache 2服务器.

因此aws必须输入以下代码ubuntu服务器.

pip install Django

sudo apt-get install appache2

sudo apt-get install libapache2-mod-wsgi-py3

然后我将Python项目和app文件夹创建为Python venv.

Apache 2 000-default.conf的代码如下:

<virtualhost *:80>
WSGIDaemonProcess bot python-path=/home/ubuntu/Django/bot:/home/ubuntu/Django/myvenv/lib/python3.5/site-packages
ServerAdmin webmaster@localhost
WSGIScriptAlias /52.78.108.223 /home/ubuntu/Django/bot/wsgi.py
<Directory /home/ubuntu/Django/bot>
<Files wsgi.py>
        Require all granted
</Files>
</Directory>

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

位置正确.没有输入错误.

'WSGIScriptAlias/'的第一个参数应该为空白,但是如果将其放在空白处,则当您点击该IP时将看不到'it walk'页面.所以我把服务器的外部IP.然后它走的很好.

查看Apache 2错误日志.

[2018年5月2日星期三21:32:28.100569] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi:为Python/3.5.1 +编译.

[2018年5月2日星期三21:32:28.100633] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi:使用Python/3.5.2.运行时

[2018年5月2日星期三21:32:28.101406] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00489:配置了Apache/2.4.18(Ubuntu)mod_wsgi/4.3.0 Python/3.5.2-恢复正常操作

[2018年5月2日星期三21:32:28.101426] [core:notice] [pid 22648:tid 140282945054592] AH00094:命令行:'/usr/sbin/apache2'

[2018年5月2日星期三21:32:28.191175] [wsgi:error] [pid 22651:tid 140282945054592] mod_wsgi(pid = 22651):调用'site.addsitedir()'失败,导致'(null)',停止.

[2018年5月2日星期三21:32:28.192041] [wsgi:error] [pid 22651:tid 140282945054592] mod_wsgi(pid = 22651):由于'/home/ubuntu/Django/myvenv/lib/python3.5/site-packages".

[2018年5月2日星期三21:33:21.733277] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00494:收到了SIGHUP.尝试重新启动

[2018年5月2日星期三21:33:21.787095] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi:为Python/3.5.1 +编译.

[2018年5月2日星期三21:33:21.787410] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi:使用Python/3.5.2.的运行时.

[2018年5月2日星期三21:33:21.788397] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00489:配置了Apache/2.4.18(Ubuntu)mod_wsgi/4.3.0 Python/3.5.2-恢复正常操作

[2018年5月2日星期三21:33:21.788447] [core:notice] [pid 22648:tid 140282945054592] AH00094:命令行:'/usr/sbin/apache2'

[2018年5月2日星期三21:33:21.860854] [wsgi:error] [pid 22781:tid 140282945054592] mod_wsgi(pid = 22781):由于'(null)'调用'site.addsitedir()'失败,停止.

[2018年5月2日星期三21:33:21.860889] [wsgi:error] [pid 22781:tid 140282945054592] mod_wsgi(pid = 22781):调用'site.addsitedir()'失败的原因是'/home/ubuntu/Django/myvenv/lib/python3.5/site-packages".

它像这样出来.

我搜索了互联网.据说wsgi版本低.

但是,apache2使用的wsgi只能与'sudo apt-get install libapache2-mod-wsgi-py3'一起安装.

Apache 2错误日志显示wsgi版本为4.3.0.

如果使用"pip install mod-wsgi"安装最新版本的wsgi,则Apache 2错误日志将显示4.3.0.

'呼叫'site.addsitedir()'失败'(null)',停止.错误日志仍会出现.

如何解决此错误?

解决方案

请勿使用mod_wsgi 4.3.0.它非常旧,并且存在内存问题,无法为python-path提供多个目录.或者使用:

WSGIDaemonProcess bot python-home=/home/ubuntu/Django/myvenv python-path=/home/ubuntu/Django/bot

您不应将site-packagespython-path一起使用.这不是推荐的方法,自mod_wsgi 3.3起就没有.

有关使用虚拟环境的更多详细信息,请参见:

如果使用pip install mod_wsgi后没有显示最新的mod_wsgi,那是因为您没有禁用/卸载系统mod_wsgi软件包.您可能需要通过运行mod_wsgi-express module-config并获取输出并将其添加到Apache配置中,来手动配置Apache以加载较新的mod_wsgi.

I would like to connect Python and Apache 2 server in Ubuntu.

So aws have to enter the following code ubuntu server.

pip install Django

sudo apt-get install appache2

sudo apt-get install libapache2-mod-wsgi-py3

Then I created the Python project and the app folder as Python venv.

The code for Apache 2 000-default.conf looks like this:

<virtualhost *:80>
WSGIDaemonProcess bot python-path=/home/ubuntu/Django/bot:/home/ubuntu/Django/myvenv/lib/python3.5/site-packages
ServerAdmin webmaster@localhost
WSGIScriptAlias /52.78.108.223 /home/ubuntu/Django/bot/wsgi.py
<Directory /home/ubuntu/Django/bot>
<Files wsgi.py>
        Require all granted
</Files>
</Directory>

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

The location is correct. There is no typing miss.

The first argument to 'WSGIScriptAlias ​​/' should be blank, but if you put it in a blank space, you will not see the 'it walked' page when you hit that IP. So I put the external IP of the server. Then it walked well.

Looking at the Apache 2 error log.

[Wed May 02 21:32:28.100569 2018] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi: Compiled for Python/3.5.1+.

[Wed May 02 21:32:28.100633 2018] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi: Runtime using Python/3.5.2.

[Wed May 02 21:32:28.101406 2018] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations

[Wed May 02 21:32:28.101426 2018] [core:notice] [pid 22648:tid 140282945054592] AH00094: Command line: '/usr/sbin/apache2'

[Wed May 02 21:32:28.191175 2018] [wsgi:error] [pid 22651:tid 140282945054592] mod_wsgi (pid=22651): Call to 'site.addsitedir()' failed for '(null)', stopping.

[Wed May 02 21:32:28.192041 2018] [wsgi:error] [pid 22651:tid 140282945054592] mod_wsgi (pid=22651): Call to 'site.addsitedir()' failed for '/home/ubuntu/Django/myvenv/lib/python3.5/site-packages'.

[Wed May 02 21:33:21.733277 2018] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00494: SIGHUP received. Attempting to restart

[Wed May 02 21:33:21.787095 2018] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi: Compiled for Python/3.5.1+.

[Wed May 02 21:33:21.787410 2018] [wsgi:warn] [pid 22648:tid 140282945054592] mod_wsgi: Runtime using Python/3.5.2.

[Wed May 02 21:33:21.788397 2018] [mpm_event:notice] [pid 22648:tid 140282945054592] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations

[Wed May 02 21:33:21.788447 2018] [core:notice] [pid 22648:tid 140282945054592] AH00094: Command line: '/usr/sbin/apache2'

[Wed May 02 21:33:21.860854 2018] [wsgi:error] [pid 22781:tid 140282945054592] mod_wsgi (pid=22781): Call to 'site.addsitedir()' failed for '(null)', stopping.

[Wed May 02 21:33:21.860889 2018] [wsgi:error] [pid 22781:tid 140282945054592] mod_wsgi (pid=22781): Call to 'site.addsitedir()' failed for '/home/ubuntu/Django/myvenv/lib/python3.5/site-packages'.

It comes out like this.

I searched the internet. It is said that wsgi version is low.

However, wsgi used by apache2 can only be installed with 'sudo apt-get install libapache2-mod-wsgi-py3'.

The Apache 2 error log shows that wsgi version is 4.3.0.

If you install the latest version of wsgi with 'pip install mod-wsgi', the Apache 2 error log will show 4.3.0.

'Call to' site.addsitedir () 'failed for' (null) ', stopping.' The error log still appears.

How do I resolve this error?

解决方案

Don't use mod_wsgi 4.3.0. It is very old and has an issue from memory with providing multiple directories to python-path. Alternatively use:

WSGIDaemonProcess bot python-home=/home/ubuntu/Django/myvenv python-path=/home/ubuntu/Django/bot

You shouldn't be using site-packages with python-path. That is not the recommended way and hasn't been since mod_wsgi 3.3.

For more details on using virtual environments, see:

If after using pip install mod_wsgi it doesn't show latest mod_wsgi, it is because you didn't disable/uninstall the system mod_wsgi package. You would need to have manually configured Apache to load the newer mod_wsgi as well, by running mod_wsgi-express module-config and taking the output and add it to Apache configuration.

这篇关于apache2错误日志.呼叫'(null)'的'site.addsitedir()'失败,停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆