apache2 webserver not executing cgi scripts?

Discuss Applications

apache2 webserver not executing cgi scripts?

Postby Ice9 » Sun Dec 03, 2006 4:08 pm

I ran the plans calendar for a couple of days on my freshly created intranet and while it's nothing that special it ran ok and suited the job.

I have done nothing special apart from my daily apt-get update/dist-upgrade and now when I run plans.cgi, it doesn't run and instead I'm now looking at the source of the cgi script.
Any ideas what I might have to change for the cgi scripts to be executed instead of just displayed on the screen?
I googled this for tha past 3 hours now and still didn't find anything useful.

One thing I noticed different is /etc/httpd.conf was empty where it contained
Code: Select all
<Directory /var/www/Intranet/plans>
        AddHandler cgi-script .cgi
        DirectoryIndex index.cgi index.html
        Options +ExecCGI
      </Directory>
befor, so I pasted it back in but it makes no difference ....

I temporarily resorted to using webcalendar and it runs fine but I would prefer to be able to use planscalendar.
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Void Main » Sun Dec 03, 2006 8:14 pm

Assuming your scripts are actually in the /var/www/Intranet/plans directory then it looks like what you have should work. The only thing different in my config is I don't put the "+" in front of the ExecCGI directive. Mine looks like this:

Code: Select all
Options Indexes FollowSymLinks ExecCGI


Do you have the execute bit set on the scripts/will they run from the command line?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Ice9 » Mon Dec 04, 2006 8:10 am

The execute bit is set and the script runs ok from the command line.
And yet all I see is source code!

I don't get it, it worked for several days.
I then replaced the content of my "webcal" folder with webcalendar, which is a php install and also works.
But then I decided that plans suited my plans a little better, created a fresh folder /plans, uncompressed the file in /var/www/Intranet/plans again, updated the premissions on the cgi file, the xml files in /data and tried to run the cgi script, without success this time ... :?
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Void Main » Mon Dec 04, 2006 10:05 am

I would need to see your httpd.conf in order to see what might be wrong. Also, make sure there is no configuration files in /etc/httpd/conf.d that are overriding any of your settings.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Ice9 » Mon Dec 04, 2006 10:11 am

The code in my first post is all that my httpd.conf contains.
And I had to put it back in there after a dist-upgrade because it was nothing but an empty file.

I'm talking about etc/apache2/httpd.conf here.
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Void Main » Mon Dec 04, 2006 10:43 am

Ahhh, this is Debian right? I forget the directory structure on that and I don't have a Debian box at the moment but I believe the configuration was split up among several files by default. You running Sid? Maybe I'll do a net install of Sid this evening and see what I can come up with if you can wait that long. As a matter of fact if I recall the last one I worked on it doesn't actually use the httpd.conf at all, everything was in virtual host configuration files.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Ice9 » Mon Dec 04, 2006 3:16 pm

Void Main wrote:
You running Sid?

Erm .... I get confused by all the name-changing with debian, I'm running "testing" currently.
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Ice9 » Mon Dec 04, 2006 3:31 pm

I no longer look at source code when trying to run plans.cgi, instead I get this. :?:
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Void Main » Mon Dec 04, 2006 4:07 pm

Your server is still not executing the script, your browser is instead trying to download it. Your add-handler and ExecCGI directives are obviously not being honored. I assume this is because your Apache installation is ignoring the httpd.conf. I am pretty sure you have to put this in a different configuration file. If I recall, there should be one for the default virtual host.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Ice9 » Mon Dec 04, 2006 4:39 pm

Think I found it, thanks to your pointers.
I went looking for virtual hosts and stumbled upon the /etc/apache2/sites-enabled/ directory.
It contained a 000-default file with
Code: Select all
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>

I commented it out and replaced it by the code previously contained by /etc/apache2/httpd.conf
Code: Select all
<Directory /var/www/Intranet/plans>
           AddHandler cgi-script .cgi
           DirectoryIndex index.cgi index.html
           Options +ExecCGI
        </Directory>

and now the cgi script is being executed.
(I find this really weird since it all was triggered by an upgrade of the box)
Not sure if it's safe to ignore the ScriptAlias thing but since this is only going to be used on my small lan I guess it won't be too much of a security issue?
Ice9
guru
guru
 
Posts: 577
Joined: Thu Jan 09, 2003 12:40 am
Location: Belgium

Postby Void Main » Mon Dec 04, 2006 5:02 pm

You wouldn't have had to comment the other stuff out. Just adding your section to it should have made it work but if you aren't going to use the other directory for CGI scripts then there is no harm in commenting them out.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Applications

Who is online

Users browsing this forum: No registered users and 1 guest