Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 09-18-2007, 11:36 AM   #1
LQ Newbie
Registered: Sep 2007
Posts: 10

Rep: Reputation: 0
Apache2 and CGI problem on Debian Etch

I have searched and tried the various things on this site and I'm still having problems with cgi scripts executing on the server. Here is part of my apache2.conf file:

# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
AddHandler cgi-script .cgi .pl

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

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory /var/www/cgi-bin>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all

I started out with the top ScriptAlias, put my script in the /usr/lib/cgi-bin directory, made sure it was chmod to 755 and then went to the site

I get a blank page. If I change the name to it tries to download the file instead of executing it. The errorlog shows this:

[Tue Sep 18 12:10:52 2007] [error] [client] (2)No such file or directory: exec of '/var/www/cgi-bin/cgitest.cgi' failed
[Tue Sep 18 12:10:52 2007] [error] [client] Premature end of script headers: cgitest.cgi

[Tue Sep 18 12:14:40 2007] [error] [client] (2)No such file or directory: exec of '/var/www/cgi-bin/' failed
[Tue Sep 18 12:14:40 2007] [error] [client] Premature end of script headers:

If I run perl -c or cgitest.cgi it says it passes. Here is the script:


# Create an HTML page to display a message.

print "Content-type: text/html\n\n";

print "<HTML><BODY><TITLE>Test</TITLE>";

print "<CENTER>";

print "<H1>";

print "TEST";

print "</H1>";

print "<HR>";

print "Hooray! It works!";

print "<HR>";

print "</CENTER>";

print "</BODY></HTML>";

I get the same errors no matter which ScriptAlias I use. Any ideas on why this isn't working?
Old 09-18-2007, 07:33 PM   #2
Senior Member
Registered: Oct 2005
Location: New Mexico
Distribution: Slackware
Posts: 1,619

Rep: Reputation: Disabled
It's looking in /var/www/cgi-bin, so try putting it there.

Old 09-19-2007, 08:28 PM   #3
LQ Newbie
Registered: Sep 2007
Posts: 10

Original Poster
Rep: Reputation: 0
I had tried both areas to place the script based on which ScriptAlias I had used. I finally got it working, I think the script was actually goofed up even though the perl check said it was OK. I think what may have happened is it got uploaded as a binary file instead of a text file, when I created a simple "hello world" script in vi on the server it worked fine. I also downloaded a couple simple scripts and they work too. Not sure what it was, but both php and cgi are working now! Thanks for the response .


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2 on Debian Etch not working finferflu Linux - Server 28 02-24-2011 05:03 AM
Debian, apache2, CGI problem daviddutch1964 Linux - Networking 1 06-29-2007 03:19 PM
Debian, apache2, CGI problem daviddutch1964 Linux - Server 0 06-29-2007 02:14 PM
Debian Sarge Apache2 Parse C cgi programs disturbed Debian 4 03-19-2006 10:03 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration