15

I'm trying to install bugzilla 4 on ubuntu 11.04

I've added the following to my httpd.conf

<Directory “/var/www/dev.spincentre/bugzilla”>
   AddHandler cgi-script .cgi
   Options +Indexes +ExecCGI
   DirectoryIndex index.cgi
   AllowOverride Limit
</Directory>

But when I go to the URL, apache shows the text of index.cgi instead of executing the script. Any idea how to fix it?

FigBug
  • 313

3 Answers3

19

Did you load the mod_cgi module? You can see if the directory /etc/apache2/mods-enabled/ has a symlink cgi.load. If there is no such symlink, you can create it by running

sudo a2enmod cgi

and then restart Apache:

sudo service apache2 restart

You can run man a2enmod to see what a2enmod does.

elmicha
  • 9,728
  • I had similar issue on Ubuntu 14.04 in a process of migration from old servers. I never thought cgi would have been disabled by default which is not with old server. This fixed it!. Plz recommend them the same at http://stackoverflow.com/questions/15199198/webserver-is-fetching-rather-than-executing-cgi-files-when-trying-to-run-bugzi. Thank you! – user3215 Jun 03 '14 at 08:08
  • I have the symlink but cgi is still not running. – Whitecat Feb 24 '16 at 00:28
2

When installing Apache 2.4 I had a number of issues to solve and also had the same issue with text showing instead of running the cgi. The solution is not the same as above, which is the solution for Apache 2.2

First, you need to download the 2.4 gz file and unpack. If you try to compile, it will complain the APR is not found, since it is no longer included. You need to download the apr and apr-util files from Apache and unpack them into the directory you are compiling Apache into the subdirectory called srclib, so your path would be ./httpd/srclib/apr and ./httpd/srclib/apr-util. You must also remove any version numbers from the directory name.

cd to your /path/httpd directory and the compile with

$ ./configure --with-included-apr

Your config will default to PREFIX=/usr/local/apache2

$ make

$ make install

$ vi PREFIX/conf/httpd.conf

You will need to edit your httpd.conf file to get your cgi's to run

In my case I did the following:

change Listen 80 to Listen 127.0.0.1:80

activate the line:

LoadModule cgid_module modules/mod_cgid.so

changed SeverName to:

ServerName 127.0.0.1:80

changed the paths in DocumentRoot and <Directory> to suit my system

changed the path in ScriptAlias

enabled the line Scriptsock cgisock

changed the path in <Directory> after the ScriptAlias to suit my system

enabled the line AddHandler cgi-script .cgi

saved the changes and started Apache with:

$ /usr/local/apache2/bin/apachectl -k start

Hope this helps anyone struggling with this ;)

MrWhite
  • 183
0

if your perl module is successfully running apache2, but when you open the page http://localhost/perl/mysite/ instead of displaying your file instead of executing the script, you only need to add a line of code to the .htaccess or apache configuration file, That is :

DirectoryIndex: index.pl index.html index.php
  • The DirectoryIndex directive should not have a colon (:) after it. (However, I don't see how this addresses the problem as stated in the question?) – MrWhite Jul 03 '20 at 21:56