按照centos 7安装教程后出现500 internal error & permission denied
500 internal error & permission denied after following the centos 7 installation tutorial
按照 "install ckan on centos 7" 教程进行一些修改(比如用 postgres 密码替换 pass 并用我自己的 ip 替换域名)后,我得到了 postgresql 和 solr(开始使用 tomcat,在端口 8080 上)和 运行。
在development.ini中,我指定了solr_url = http://127.0.0.1:8080/solr/ckan-schema-2.3,我觉得应该没问题。
curl http://127.0.0.1:8080/solr/
Response:
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css">
<link rel="icon" href="favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="favicon.ico" type="image/ico"></link>
<title>Welcome to Solr</title>
</head>
<body>
<h1>Welcome to Solr!</h1>
<a href="."><img border="0" align="right" height="78" width="142" src="admin/solr_small.png" alt="Solr"/></a>
<a href="ckan-schema-2.3/admin/">Admin ckan-schema-2.3</a><br/>
<a href="ckan-schema-1.4/admin/">Admin ckan-schema-1.4</a><br/>
</body>
</html>
curl -s 'http://127.0.0.1:8080/solr/admin/cores?wt=json&indent=true'
{
"responseHeader":{
"status":0,
"QTime":6},
"status":{
"ckan-schema-2.3":{
"name":"ckan-schema-2.3",
"instanceDir":"/usr/share/solr/core0/",
"dataDir":"/var/lib/solr/data/core0/",
"startTime":"2017-10-12T02:13:14.678Z",
"uptime":129083472,
"index":{
"numDocs":0,
"maxDoc":0,
"version":1507774394724,
"optimized":false,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NIOFSDirectory:org.apache.lucene.store.NIOFSDirectory@/var/lib/solr/data/core0/index",
"lastModified":"2017-10-12T02:13:14Z"}},
"ckan-schema-1.4":{
"name":"ckan-schema-1.4",
"instanceDir":"/usr/share/solr/core1/",
"dataDir":"/var/lib/solr/data/core1/",
"startTime":"2017-10-12T02:13:15.599Z",
"uptime":129082552,
"index":{
"numDocs":0,
"maxDoc":0,
"version":1507774395601,
"optimized":false,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NIOFSDirectory:org.apache.lucene.store.NIOFSDirectory@/var/lib/solr/data/core1/index",
"lastModified":"2017-10-12T02:13:15Z"}}}}
curl -s 'http://127.0.0.1:8080/solr/ckan-schema-2.3/admin/ping?wt=json&indent=true'
{
"responseHeader":{
"status":0,
"QTime":8,
"params":{
"echoParams":"all",
"q":"solrpingquery",
"qt":"standard",
"echoParams":"all",
"wt":"json",
"indent":"true"}},
"status":"OK"}
但是,当我在远程浏览器和本地主机中访问 CKAN 时,我遇到了内部服务器错误 (500)。
检查ckan.error.log后,我发现了以下错误信息,我认为这可能是CKAN(2.4.1)和Solr(1.4.1)之间的连接问题。
link 我遵循的教程:https://github.com/ckan/ckan/wiki/How-to-install-CKAN-2.x-on-CentOS-7
[Thu Oct 12 02:42:57.185548 2017] [:error] [pid 2438] 2017-10-12 02:42:57,184 ERROR [ckan.lib.search.common] [Errno 13] Permission denied
[Thu Oct 12 02:42:57.185581 2017] [:error] [pid 2438] Traceback (most recent call last):
[Thu Oct 12 02:42:57.185584 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/src/ckan/ckan/lib/search/common.py", line 51, in is_available
[Thu Oct 12 02:42:57.185586 2017] [:error] [pid 2438] conn.query("*:*", rows=1)
[Thu Oct 12 02:42:57.185588 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 703, in query
[Thu Oct 12 02:42:57.185590 2017] [:error] [pid 2438] return self.select(*args, **params)
[Thu Oct 12 02:42:57.185592 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 798, in __call__
[Thu Oct 12 02:42:57.185594 2017] [:error] [pid 2438] xml = self.raw(**params)
[Thu Oct 12 02:42:57.185596 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 823, in raw
[Thu Oct 12 02:42:57.185598 2017] [:error] [pid 2438] rsp = conn._post(self.selector, request, conn.form_headers)
[Thu Oct 12 02:42:57.185600 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 646, in _post
[Thu Oct 12 02:42:57.185602 2017] [:error] [pid 2438] self._reconnect()
[Thu Oct 12 02:42:57.185603 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 625, in _reconnect
[Thu Oct 12 02:42:57.185605 2017] [:error] [pid 2438] self.conn.connect()
[Thu Oct 12 02:42:57.185607 2017] [:error] [pid 2438] File "/usr/lib64/python2.7/httplib.py", line 807, in connect
[Thu Oct 12 02:42:57.185609 2017] [:error] [pid 2438] self.timeout, self.source_address)
[Thu Oct 12 02:42:57.185610 2017] [:error] [pid 2438] File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
[Thu Oct 12 02:42:57.185612 2017] [:error] [pid 2438] raise err
[Thu Oct 12 02:42:57.185614 2017] [:error] [pid 2438] error: [Errno 13] Permission denied
[Thu Oct 12 02:42:57.185715 2017] [:error] [pid 2438] 2017-10-12 02:42:57,185 WARNI [ckan.lib.search] Problems were found while connecting to the SOLR server
[Thu Oct 12 02:42:57.222342 2017] [:error] [pid 2438] [remote 100.36.143.168:224] mod_wsgi (pid=2438): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
[Thu Oct 12 02:42:57.222360 2017] [:error] [pid 2438] [remote 100.36.143.168:224] mod_wsgi (pid=2438): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
[Thu Oct 12 02:42:57.222381 2017] [:error] [pid 2438] [remote 100.36.143.168:224] Traceback (most recent call last):
[Thu Oct 12 02:42:57.222396 2017] [:error] [pid 2438] [remote 100.36.143.168:224] File "/etc/ckan/default/apache.wsgi", line 9, in <module>
[Thu Oct 12 02:42:57.222449 2017] [:error] [pid 2438] [remote 100.36.143.168:224] application = loadapp('config:%s' % config_filepath)
是的,这个错误信息是关键之一:
Problems were found while connecting to the SOLR server
那些 CKAN Centos 安装说明将 CKAN 配置为:
solr_url=http://127.0.0.1:8080/solr/ckan-schema-2.3
当 CKAN 尝试 运行 使用 URL 的 SOLR 查询时,它失败了。具体来说,它无法连接到 127.0.0.1:8080,这通常意味着没有任何东西在监听,即可能 SOLR 不是 运行ning。所以这听起来像是一个纯粹的 SOLR 问题,而不是 CKAN 问题。
首先检查 SOLR 是否 运行正在其主管理界面上进行响应:
curl http://127.0.0.1:8080/solr/
现在检查是否配置了CKAN所需的SOLR内核:
curl -s 'http://127.0.0.1:8080/solr/admin/cores?wt=json&indent=true'
CKAN SOLR 内核如下所示:
"ckan":{
"name":"ckan",
"instanceDir":"/etc/solr/ckan/",
"dataDir":"/var/lib/solr/data/",
"startTime":"2017-10-13T10:32:01.3Z",
"uptime":1805340,
"index":{
"numDocs":50,
"maxDoc":52,
"version":1490867603581,
"segmentCount":9,
"current":true,
"hasDeletions":true,
"directory":"org.apache.lucene.store.MMapDirectory:org.apache.lucene.store.MMapDirectory@/var/lib/solr/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory@4b3e213f",
"lastModified":"2017-10-13T10:44:47Z"}}
Centos 安装指南为您提供了两个内核,尽管您只需要后一个内核——忽略旧的 schema-1.4 内核。检查 schema-2.3 的名字(核心的前 2 行)是否设置为:ckan-schema-2.3
,按照你的 solr_url
中的最后一位(我在 ckan
上面的例子,这是默认的)。
您可以像这样检查 SOLR 核心的状态:
curl -s 'http://127.0.0.1:8983/solr/ckan-schema-2.3/admin/ping?wt=json&indent=true'
检查它的结尾:"status":"OK"
这可能是创建套接字连接的权限问题。这可能与 SELinux 有关。查看 SELinux 强制是否打开:
getenforce
如果是,您需要阅读有关套接字的权限。
按照 "install ckan on centos 7" 教程进行一些修改(比如用 postgres 密码替换 pass 并用我自己的 ip 替换域名)后,我得到了 postgresql 和 solr(开始使用 tomcat,在端口 8080 上)和 运行。
在development.ini中,我指定了solr_url = http://127.0.0.1:8080/solr/ckan-schema-2.3,我觉得应该没问题。
curl http://127.0.0.1:8080/solr/
Response:
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css">
<link rel="icon" href="favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="favicon.ico" type="image/ico"></link>
<title>Welcome to Solr</title>
</head>
<body>
<h1>Welcome to Solr!</h1>
<a href="."><img border="0" align="right" height="78" width="142" src="admin/solr_small.png" alt="Solr"/></a>
<a href="ckan-schema-2.3/admin/">Admin ckan-schema-2.3</a><br/>
<a href="ckan-schema-1.4/admin/">Admin ckan-schema-1.4</a><br/>
</body>
</html>
curl -s 'http://127.0.0.1:8080/solr/admin/cores?wt=json&indent=true'
{
"responseHeader":{
"status":0,
"QTime":6},
"status":{
"ckan-schema-2.3":{
"name":"ckan-schema-2.3",
"instanceDir":"/usr/share/solr/core0/",
"dataDir":"/var/lib/solr/data/core0/",
"startTime":"2017-10-12T02:13:14.678Z",
"uptime":129083472,
"index":{
"numDocs":0,
"maxDoc":0,
"version":1507774394724,
"optimized":false,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NIOFSDirectory:org.apache.lucene.store.NIOFSDirectory@/var/lib/solr/data/core0/index",
"lastModified":"2017-10-12T02:13:14Z"}},
"ckan-schema-1.4":{
"name":"ckan-schema-1.4",
"instanceDir":"/usr/share/solr/core1/",
"dataDir":"/var/lib/solr/data/core1/",
"startTime":"2017-10-12T02:13:15.599Z",
"uptime":129082552,
"index":{
"numDocs":0,
"maxDoc":0,
"version":1507774395601,
"optimized":false,
"current":true,
"hasDeletions":false,
"directory":"org.apache.lucene.store.NIOFSDirectory:org.apache.lucene.store.NIOFSDirectory@/var/lib/solr/data/core1/index",
"lastModified":"2017-10-12T02:13:15Z"}}}}
curl -s 'http://127.0.0.1:8080/solr/ckan-schema-2.3/admin/ping?wt=json&indent=true'
{
"responseHeader":{
"status":0,
"QTime":8,
"params":{
"echoParams":"all",
"q":"solrpingquery",
"qt":"standard",
"echoParams":"all",
"wt":"json",
"indent":"true"}},
"status":"OK"}
但是,当我在远程浏览器和本地主机中访问 CKAN 时,我遇到了内部服务器错误 (500)。
检查ckan.error.log后,我发现了以下错误信息,我认为这可能是CKAN(2.4.1)和Solr(1.4.1)之间的连接问题。
link 我遵循的教程:https://github.com/ckan/ckan/wiki/How-to-install-CKAN-2.x-on-CentOS-7
[Thu Oct 12 02:42:57.185548 2017] [:error] [pid 2438] 2017-10-12 02:42:57,184 ERROR [ckan.lib.search.common] [Errno 13] Permission denied
[Thu Oct 12 02:42:57.185581 2017] [:error] [pid 2438] Traceback (most recent call last):
[Thu Oct 12 02:42:57.185584 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/src/ckan/ckan/lib/search/common.py", line 51, in is_available
[Thu Oct 12 02:42:57.185586 2017] [:error] [pid 2438] conn.query("*:*", rows=1)
[Thu Oct 12 02:42:57.185588 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 703, in query
[Thu Oct 12 02:42:57.185590 2017] [:error] [pid 2438] return self.select(*args, **params)
[Thu Oct 12 02:42:57.185592 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 798, in __call__
[Thu Oct 12 02:42:57.185594 2017] [:error] [pid 2438] xml = self.raw(**params)
[Thu Oct 12 02:42:57.185596 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 823, in raw
[Thu Oct 12 02:42:57.185598 2017] [:error] [pid 2438] rsp = conn._post(self.selector, request, conn.form_headers)
[Thu Oct 12 02:42:57.185600 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 646, in _post
[Thu Oct 12 02:42:57.185602 2017] [:error] [pid 2438] self._reconnect()
[Thu Oct 12 02:42:57.185603 2017] [:error] [pid 2438] File "/usr/lib/ckan/default/lib/python2.7/site-packages/solr/core.py", line 625, in _reconnect
[Thu Oct 12 02:42:57.185605 2017] [:error] [pid 2438] self.conn.connect()
[Thu Oct 12 02:42:57.185607 2017] [:error] [pid 2438] File "/usr/lib64/python2.7/httplib.py", line 807, in connect
[Thu Oct 12 02:42:57.185609 2017] [:error] [pid 2438] self.timeout, self.source_address)
[Thu Oct 12 02:42:57.185610 2017] [:error] [pid 2438] File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
[Thu Oct 12 02:42:57.185612 2017] [:error] [pid 2438] raise err
[Thu Oct 12 02:42:57.185614 2017] [:error] [pid 2438] error: [Errno 13] Permission denied
[Thu Oct 12 02:42:57.185715 2017] [:error] [pid 2438] 2017-10-12 02:42:57,185 WARNI [ckan.lib.search] Problems were found while connecting to the SOLR server
[Thu Oct 12 02:42:57.222342 2017] [:error] [pid 2438] [remote 100.36.143.168:224] mod_wsgi (pid=2438): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
[Thu Oct 12 02:42:57.222360 2017] [:error] [pid 2438] [remote 100.36.143.168:224] mod_wsgi (pid=2438): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
[Thu Oct 12 02:42:57.222381 2017] [:error] [pid 2438] [remote 100.36.143.168:224] Traceback (most recent call last):
[Thu Oct 12 02:42:57.222396 2017] [:error] [pid 2438] [remote 100.36.143.168:224] File "/etc/ckan/default/apache.wsgi", line 9, in <module>
[Thu Oct 12 02:42:57.222449 2017] [:error] [pid 2438] [remote 100.36.143.168:224] application = loadapp('config:%s' % config_filepath)
是的,这个错误信息是关键之一:
Problems were found while connecting to the SOLR server
那些 CKAN Centos 安装说明将 CKAN 配置为:
solr_url=http://127.0.0.1:8080/solr/ckan-schema-2.3
当 CKAN 尝试 运行 使用 URL 的 SOLR 查询时,它失败了。具体来说,它无法连接到 127.0.0.1:8080,这通常意味着没有任何东西在监听,即可能 SOLR 不是 运行ning。所以这听起来像是一个纯粹的 SOLR 问题,而不是 CKAN 问题。
首先检查 SOLR 是否 运行正在其主管理界面上进行响应:
curl http://127.0.0.1:8080/solr/
现在检查是否配置了CKAN所需的SOLR内核:
curl -s 'http://127.0.0.1:8080/solr/admin/cores?wt=json&indent=true'
CKAN SOLR 内核如下所示:
"ckan":{
"name":"ckan",
"instanceDir":"/etc/solr/ckan/",
"dataDir":"/var/lib/solr/data/",
"startTime":"2017-10-13T10:32:01.3Z",
"uptime":1805340,
"index":{
"numDocs":50,
"maxDoc":52,
"version":1490867603581,
"segmentCount":9,
"current":true,
"hasDeletions":true,
"directory":"org.apache.lucene.store.MMapDirectory:org.apache.lucene.store.MMapDirectory@/var/lib/solr/data/index lockFactory=org.apache.lucene.store.NativeFSLockFactory@4b3e213f",
"lastModified":"2017-10-13T10:44:47Z"}}
Centos 安装指南为您提供了两个内核,尽管您只需要后一个内核——忽略旧的 schema-1.4 内核。检查 schema-2.3 的名字(核心的前 2 行)是否设置为:ckan-schema-2.3
,按照你的 solr_url
中的最后一位(我在 ckan
上面的例子,这是默认的)。
您可以像这样检查 SOLR 核心的状态:
curl -s 'http://127.0.0.1:8983/solr/ckan-schema-2.3/admin/ping?wt=json&indent=true'
检查它的结尾:"status":"OK"
这可能是创建套接字连接的权限问题。这可能与 SELinux 有关。查看 SELinux 强制是否打开:
getenforce
如果是,您需要阅读有关套接字的权限。