LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2015, 10:20 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Rep: Reputation: 52
I cannot get cgi scripts to work in Apache2. Debian 7 stock install.


I thought I had Apache2 configured properly according to the instructions on Apache site on my testing machine as it looks simple enough with /etc/apache2/sites_available/default as follows:
Code:
	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
	ScriptAlias "/cgi-bin/" "/usr/lib/cgi-bin/" # tried first outside of quotes
	AddHandler cgi-script .cgi .yab .pl# tried without it here
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#		AddHandler cgi-script .cgi .yab	.pl# tried uncommented
		Order allow,deny
		Allow from all
	</Directory>
Code:
drwxr-sr-x 2 Paul users 4096 Jul 30 22:03 cgi-bin
# tried with different owners
I have the following scripts in /usr/lib/cgi-bin/ the first script is written in yabasic (.yab) I do not know Perl.
Code:
-rwxr-xr-x 1 Paul users 93 Jul 30 20:24 basic_testing.yab
Code:
#!/usr/local/bin/yabasic	#(this line is correct)
print "Content-type: text/html"
print: print-: print "It works."
end
Code:
-rwxr-xr-x 1 Paul users 76 Jul 30 21:26 perl_testing.pl
#!/usr/bin/perl		#(this line is correct)
print "Content-type: text/html\n\n";
print "Hello, World.";
and the 2 calling scripts in /var/www/html/en/poli/
form_test.yab.htm
Code:
<html><body><head><title></title></head><form method="post" action="/usr/lib/cgi-bin/basic_testing.yab"><input type="submit" value="Submit"></form></body></html>
this was first tried with relative path (/cgi-bin/) which gave a file not found through the browser

form_test.pl.htm
Code:
<html><body><head><title></title></head><form method="post" action="/usr/lib/cgi-bin/perl_testing.pl"><input type="submit" value="Submit"></form></body></html>
"apache2ctl restart" was issued after each modification of the config file

running form_test.yab.htm script in the browser prints the contents of basic_testing.yab while running form_test.pl.htm in the browser asks if perl_testing.pl should be open or saved. There is nothing in the logs. apachectl configtest says syntax OK

Can anyone tell me where my mistake is?

Thank you for your help.

Last edited by rblampain; 07-30-2015 at 10:20 PM.
 
Old 07-30-2015, 11:49 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Off: Please use [code] and [/code] tags.
On: File extension .cgi might be more suitable for CGI programs than .pl or .htm
 
Old 07-30-2015, 11:35 PM   #3
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
To NevemTeve
There is no
Code:
.htm
extension in the cgi scripts and changing the cgi extension from
Code:
.yab
or
Code:
.pl
to
Code:
.cgi
makes no difference and I have never seen anything in any Apache instruction suggesting it might.
I always try to be meticulous in my questions although I regularly fail miserably, it seems you tend to rush when you read questions since my previous post regarding "onclick", which you complained about, was never about the onclick event but about the onclick side-effect of the onMouse event, a misunderstanding I thought would confuse things even more if I tried to correct it. However, other volunteers like yourself may lose interest in a post when they get the impression the question is a lot more basic than it really is and I have found if a valid answer is not given as the first answer, even if it needs to be expanded, it is likely there will be no valid answer to the question. I must say that I have a lot of sympathy for people like you because it can be very frustrating to provide knowledge free of charge to help someone else (lq or any business) to succeed, all the computer-related work I do is as a volunteer for a Not-For-Profit.

I suspect all the code explained above is correct according to Apache instructions which are outdated (I read this on the Internet) or not matching the use of Apache2 made by Debian 7, the problem is to identify which.

Last edited by rblampain; 07-30-2015 at 11:42 PM.
 
Old 07-31-2015, 12:40 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I think you should install all your files into the same directory (e.g.: /home/yourusername/public_html).

Code:
$ cat ~/public_html/basic_testing.html
<html>
<head><title>No Title</title></head>
<body>
 <form method="post" action="basic_testing.cgi">
  <input type="submit" value="Submit">
 </form>
</body>
</html>
Whenever you experience a problem, consult file /var/log/apache2/error_log
 
Old 08-10-2015, 12:53 AM   #5
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
My apologies for the delay, the problem had to be shelved for a while. Sleeping on it showed I made a big mistake somewhere and probably made it worse as I tried, entering the correct code in the browser showed there was nothing wrong with anything, entering:
Code:
http://127.0.0.1/cgi-bin/perl_testing.pl
worked.
 
  


Reply



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
[SOLVED] configure apache2 -- to run cgi perl scripts. casperdaghost Linux - Software 5 02-23-2012 07:27 PM
Debian Apache2 rewriting subdirectory to root breaks accessing cgi scripts sweetie_lolz3 Linux - Server 1 05-25-2010 04:02 PM
setting up cgi scripts on apache2 jabberwok Linux - Server 18 07-14-2009 12:07 AM
Apache2 on Debian won't execute perl cgi scripts, have tried chmod, Options ExecCGI dewert Linux - Software 1 07-03-2006 12:44 PM
Getting CGI scripts to work Cool_Hand_Luke Linux - Newbie 5 03-09-2005 05:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:44 PM.

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