8

This is a self-answered question that describes how to resolve problems that occur when installing the brat annotation tool, which is used to create annotated corpora for use in NLP, on an ordinary Linux machine that has SELinux enabled. This is based on version 1.3 of the tool.

The installation procedure as documented includes the steps below:

  1. Unpack the .tar.gz file in an (Apache) web server directory, typically /var/www/html or $HOME/public_html
  2. Possibly rename the unpacked directory from brat-v1.3_Crunchy_Frog to something simple such as brat
  3. Enter the directory and run sudo ./install.sh
  4. Start the web server (sudo service httpd start) if it wasn't running already

Problem: When following this procedure, any attempt to use brat in a browser (by directing it to http://localhost/brat/index.xhtml fails with the following error messages displayed on screen:

Error: ActiongetCollectionInformation failed on error Internal Server Error
Error: Actionwhoami failed on error Internal Server Error
Error: ActionloadConf failed on error Internal Server Error

The Apache error log (typically found in /var/log/httpd/error_log) also shows errors:

(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

How to solve this problem?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
jogojapan
  • 68,383
  • 11
  • 101
  • 131

2 Answers2

4

This is caused by SELinux. One way to solve it is to disable SELinux, but a somewhat less radical method is to set access rights as required by brat.

The roots of the problem are:

  1. brat keeps executable scripts (CGI scripts), static files as well as annotated data all in the same directory, the html directory
  2. SELinux is, by default, configured to prevent the execution of CGI scripts from non-CGI directories. Merely changing the Apache configuration does not help here
  3. SELinux is also configured to prevent CGI scripts writing data to disk

To modify the SELinux configuration, you need to give access rights to specific files and directories as follows (do this from within the brat installation directory):

$> 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

($> represents the command prompt.)

The first command enables read access to the current directory (it may sometimes unnecessary). The second command enables CGI script execution of all files ending in .cgi (this is necessary). The third command enables write access to the work and data directory (also necessary); it needs to be applied again whenever you add files or subdirectories to work or `data.

jogojapan
  • 68,383
  • 11
  • 101
  • 131
  • Dear jogojapan,I have the same issue as OP, my machine is as follows: $ uname -a Linux shibamouli 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic I tried the above solutions, they didn't work. Could you please let me know if you had any other ideas.. Have a great day! Best, Shibamouli – Shibamouli Lahiri Jun 12 '18 at 22:52
0

I had same issue. Able to resolve it by changing /etc/apache2/apache2.conf file as following.

<Directory /var/www>
    Options Indexes FollowSymLinks
    #AllowOverride Options Indexes FileInfo
    Require all granted
    AddType application/xhtml+xml .xhtml
    AddType font/ttf .ttf
    # For CGI support
    AddHandler cgi-script .cgi
    # Comment out the line above and uncomment the line below for FastCGI
    #AddHandler fastcgi-script fcgi
</Directory>

<Directory /var/www/html>
    Options Indexes FollowSymLinks
    #AllowOverride Options Indexes FileInfo
    Require all granted
    AddType application/xhtml+xml .xhtml
    AddType font/ttf .ttf
    # For CGI support
    AddHandler cgi-script .cgi
    # Comment out the line above and uncomment the line below for FastCGI
    #AddHandler fastcgi-script fcgi
</Directory>

<Directory /var/www/html/brat>
    Options Indexes FollowSymLinks
    AllowOverride Options Indexes FileInfo
    Require all granted
    AddType application/xhtml+xml .xhtml
    AddType font/ttf .ttf
    # For CGI support
    #AddHandler cgi-script .cgi
    # Comment out the line above and uncomment the line below for FastCGI
    AddHandler fastcgi-script fcgi
    # For FastCGI, Single user installs should be fine with anything over 8
    #FastCgiConfig -maxProcesses 8
</Directory>

Refrence: Brat issue

iamabhaykmr
  • 1,803
  • 3
  • 24
  • 49