0

I am trying to launch my own mediawiki site and I am having some trouble with the math extension mimetex. In order to enable math equations to display properly on the site you need a .cgi-file working in the background. I compiled the mimetex-cgi file and put it in a folder I made in my mediawiki directory (/etc/mediawiki/cgi-bin). The file is called mimetex.cgi.

However, when I navigate to the file on my webserver it does not generate the image I want (which it is supposed to do), instead it asks me to download the file.

I'm pretty sure the file works properly since I was able to run it on my server. My guess is that I should enable something in apache but I don't know what. I looked at this question and tried the answer here but it didn't work (Apache 403 error (Forbidden) on windows). I entered the Directory-snippet to my apache2.conf but it did not work.

Does anyone know how to enable the running of .cgi-files through a webbrowser?

EDIT: This is what I wrote in my apache-config (/etc/apache2/apache2.conf)

<Directory /etc/mediawiki/cgi-bin/>
  AddHandler cgi-script .cgi .pl
  Options FollowSymLinks +ExecCGI
  AllowOverride None
</Directory>

EDIT2: New problem Added this to config:

<Directory /etc/mediawiki/cgi-bin/>
  AddHandler cgi-script .cgi .pl
  Options FollowSymLinks +ExecCGI
  AllowOverride None
</Directory>

AddHandler cgi-script .cgi .pl

It seems like it recognizes that the user wants to run the file. Now I have this problem instead:

You don't have permission to access /mediawiki/cgi-bin/mimetex.cgi on this server.

EDIT3:What my permissions are

$ls -l /etc/mediawiki/cgi-bin/
-rwxrwxrwx 1 www-data www-data 1359104 Jan  9 01:24 mimetex.cgi

$ls -ld /etc/mediawiki/cgi-bin/
drwxrwxrwx 2 www-data www-data 4096 Jan  9 01:43 /etc/mediawiki/cgi-bin/

My user is: www-data from what I can tell.

Community
  • 1
  • 1
OXp1845
  • 483
  • 2
  • 6
  • 20
  • Related: http://stackoverflow.com/questions/5083003/execute-a-cgi-file-in-ubuntu, http://stackoverflow.com/questions/14792978/perl-apache-perl-script-displayed-as-plain-text – ThisSuitIsBlackNot Jan 09 '14 at 16:41
  • For security reasons, you probably shouldn't put your `AddHandler` directive outside of the `` block, unless you want Apache to be able to run scripts from *any* directory in the `DocumentRoot`. As for your permissions issue, make sure your CGI script is executable by the Apache user. – ThisSuitIsBlackNot Jan 09 '14 at 19:08
  • How do I make it executable by a apacheuser? – OXp1845 Jan 09 '14 at 19:10
  • First figure out the Apache user and group. These are set by the `User` and `Group` directives in your main Apache conf file (`/etc/httpd/conf/httpd.conf` on my system). The user is generally either `apache` or `nobody`. Next `chown` the file, e.g. `chown apache:apache /path/to/file`. – ThisSuitIsBlackNot Jan 09 '14 at 19:16
  • And make sure the file has execute permission for user and group: `chmod ug+x /path/to/file` – ThisSuitIsBlackNot Jan 09 '14 at 19:57
  • Hmm, still no change. I'm hosting it on a raspberry pi if that helps :P – OXp1845 Jan 09 '14 at 21:13
  • Did you reload the Apache configuration after changing it? Have you checked the Apache error log? Update your question with the permissions of the script and the `cgi-bin` directory: `ls -l /etc/mediawiki/cgi-bin/`; as well as the `User` and `Group` directives from `httpd.conf`. – ThisSuitIsBlackNot Jan 09 '14 at 21:18
  • And the permissions of the `/etc/mediawiki/cgi-bin/` directory itself are? – ThisSuitIsBlackNot Jan 09 '14 at 21:52
  • drwxrwxrwx 2 www-data www-data 4096 Jan 9 01:43 /etc/mediawiki/cgi-bin/ – OXp1845 Jan 09 '14 at 23:51

1 Answers1

1

Finally solved it!

1.Moved my cgi-file (mimetex.cgi) to /usr/lib/cgi-bin/

2.Changed apache2.conf to:

<Directory /usr/lib/cgi-bin/>
   AddHandler cgi-script .cgi .pl
  Options +FollowSymLinks +ExecCGI
  AllowOverride None  
</Directory>

AddHandler cgi-script .cgi .pl

3.Changed the /etc/apache2/sites-enabled/000-default file to:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
   AllowOverride None
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   Order allow,deny
   Allow from all
</Directory>

4.Did chmod 755

$sudo chmod 755 /usr/lib/cgi-bin
$sudo chmod 755 /usr/lib/cgi-bin/mimetex.cgi
OXp1845
  • 483
  • 2
  • 6
  • 20