如何在启用了SELinux的Linux机器上安装brat注释工具

jog*_*pan 7 nlp brat

这是一个自我回答的问题,描述了如何解决安装brat注释工具时出现的问题,该工具用于在启用了SELinux的普通Linux机器上创建用于NLP的注释语料库.这基于该工具的1.3版.

作为安装程序记录包括以下步骤:

  1. 将.tar.gz文件解压缩到(Apache)Web服务器目录中,通常/var/www/html$HOME/public_html
  2. 可能会将解压缩的目录重命名为brat-v1.3_Crunchy_Frog简单的目录,例如brat
  3. 输入目录并运行 sudo ./install.sh
  4. sudo service httpd start如果尚未运行,请启动Web服务器()

问题:在执行此过程时,任何尝试在浏览器中使用brat(通过将其指向http://localhost/brat/index.xhtml失败,并在屏幕上显示以下错误消息:

Error: ActiongetCollectionInformation failed on error Internal Server Error
Error: Actionwhoami failed on error Internal Server Error
Error: ActionloadConf failed on error Internal Server Error
Run Code Online (Sandbox Code Playgroud)

Apache错误日志(通常位于/var/log/httpd/error_log)中也显示错误:

(13)Permission denied: exec of '/var/www/html/new/ajax.cgi' failed, referer: http://localhost/new/index.xhtml
Premature end of script headers: ajax.cgi, referer: http://localhost/new/index.xhtml
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题呢?

jog*_*pan 4

这是SELinux 造成的。解决这个问题的一种方法是禁用 SELinux,但另一种不太激进的方法是根据 brat 的要求设置访问权限。

问题的根源是:

  1. brat 将可执行脚本(CGI 脚本)、静态文件以及带注释的数据都保存在同一目录中,该html目录
  2. 默认情况下,SELinux 配置为阻止从非 CGI 目录执行 CGI 脚本。仅仅更改 Apache 配置在这里没有帮助
  3. SELinux 还被配置为阻止 CGI 脚本将数据写入磁盘

要修改 SELinux 配置,您需要授予特定文件和目录的访问权限,如下所示(在 brat 安装目录中执行此操作):

$> chcon -t httpd_sys_content_t .
$> chcon -t httpd_sys_script_exec_t *.cgi
$> sudo chcon -R -t httpd_sys_script_rw_t work data
Run Code Online (Sandbox Code Playgroud)

$>代表命令提示符。)

第一个命令启用对当前目录的读访问(有时可能是不必要的)。第二个命令启用 CGI 脚本执行所有以 结尾的文件.cgi(这是必要的)。第三个命令启用对workanddata目录的写访问(也是必需的);work每当您将文件或子目录添加到“data.txt”或“data.txt”时,都需要再次应用它。