ckan.site_url 中的 IP 地址未被 ckan db init 接受

IP address in ckan.site_url not accepted by ckan db init

我正在 Ubuntu 16.04 VM 上关注 CKAN 2.8 的 official installation procedure from package,没有域(可通过 IP 地址访问)。

我已经使用 HTTP URL 配置了 /etc/ckan/default/ckan.ini 到 VM (ckan.site_url = http://192.168.56.101:80) 但是当我调用 ckan db init 它 returns 错误 ckan.site_url is not configured and it must have a value。我还尝试了 URL 的其他变体,但其中 none 有效:

我做错了什么?

下面可以看到/etc/ckan/default/ckan.ini的内容和ckan db init的输出。

daniele@ckantest:~$ cat /etc/ckan/default/ckan.ini
solr_url = http://127.0.0.1:8983/solr
ckan.site_id = ckan-demo
ckan.site_url = http://192.168.56.101:80

daniele@ckantest:~$ sudo ckan db init
Traceback (most recent call last):
  File "/usr/bin/ckan", line 45, in <module>
    load_entry_point('PasteScript', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 357, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 330, in _load_config
    self.site_user = load_config(self.options.config, load_site_user)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 237, in load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 116, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 130, in load_all
    unload_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 183, in unload_all
    unload(*reversed(_PLUGINS))
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 211, in unload
    plugins_update()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 122, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 190, in update_config
    'ckan.site_url is not configured and it must have a value.'
RuntimeError: ckan.site_url is not configured and it must have a value. Please amend your .ini file.

编辑:

我添加了一个将 ckan.demo 链接到 192.168.56.101 的主机名规则,然后使用主机名编辑了 ckan.ini,但错误仍然存​​在。显然错误不是由IP引起的,而是其他原因引起的。

下面可以看到/etc/hosts的内容,/etc/ckan/default/ckan.ini的内容和ckan db init的输出。

daniele@ckantest:~$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       ckantest

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.56.101 ckan.demo

daniele@ckantest:~$ nmap ckan.demo

Starting Nmap 7.01 ( https://nmap.org ) at 2020-05-05 14:26 CEST
Nmap scan report for ckan.demo (192.168.56.101)
Host is up (0.000044s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
8080/tcp open  http-proxy
8800/tcp open  sunwebadmin

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
daniele@ckantest:~$ cat /etc/ckan/default/ckan.ini
solr_url = http://127.0.0.1:8983/solr
ckan.site_id = ckan-demo
ckan.site_url = http://ckan.demo
daniele@ckantest:~$ sudo ckan db init
Traceback (most recent call last):
  File "/usr/bin/ckan", line 45, in <module>
    load_entry_point('PasteScript', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 357, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 330, in _load_config
    self.site_user = load_config(self.options.config, load_site_user)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 237, in load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 116, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 130, in load_all
    unload_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 183, in unload_all
    unload(*reversed(_PLUGINS))
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 211, in unload
    plugins_update()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 122, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 190, in update_config
    'ckan.site_url is not configured and it must have a value.'
RuntimeError: ckan.site_url is not configured and it must have a value. Please amend your .ini file.

您是否可能忘记提供配置文件的位置?

ckan -c /etc/ckan/default/ckan.ini db init

干杯,弗洛里安