LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-20-2003, 11:25 AM   #1
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Rep: Reputation: 30
Configuring Apache for CGI


I'm not sure exactly what my ScriptAliasing line should be in the httpd.conf for me to be able to run CGI scripts on my computer. Is it as simple as the path to the Perl 'compiler'??

Do I need to do anything else to be able to run my CGI scripts??

Thanks
 
Old 11-20-2003, 12:49 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Your ScriptAlias line in your httpd.conf file should look something like this:

Code:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 
Old 11-20-2003, 01:34 PM   #3
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
Ok, my line says that exactly. What about this:



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


Does any of this need to change??
 
Old 11-20-2003, 05:11 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by jacksmash
Ok, I'm going to try this one more time. Nobody so far has been able to help unfortunately. I'm very new to Linux, however, I would like to set up my machine so I can run cgi-scripts, php etc. So one thing at a time. I'm trying to get cgi to run properly.
I installed RedHat 9.0. I'm assuming it has apache installed already. My question is:

how do I check if apache is configured properly??

I went to /etc/httpd/conf/httpd.conf and was able to look at the file. The ScriptAlias says /cgi-bin/ "/var/www/cgi-bin/"

I'm assuming this is correct.

But my browser just displays my source code when I try to run a perl program. For example:

#!/usr/local/bin/perl -w
print "Content-type: text/html \n\n";
print "This is a test";


Can anyone help me with this??? people have already directed my to lampp, and that is not the route I want to go. I really want to learn this stuff.

Appreciate any suggestions.
Did you make sure your cgi script in your cgi-bin is executable?

chmod +x <name-of-file>
 
Old 11-20-2003, 05:14 PM   #5
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
Of course yes.
 
Old 11-20-2003, 05:24 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Something wrong with your config file then or missing something. Script works on my end but are you sure perl is located in /usr/local/bin and not just in /usr/bin ? That is usually the default location of perl.
 
Old 11-20-2003, 05:27 PM   #7
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
i've actually tried running the script both ways - with the "/local" and without - simply because I can find Perl under both directories.

Maybe another problem is this:

when I run the file from my browser, do I just type in the path to it exactly the way it is? For example, /var/www/cgi-bin/test.pl is the path to my perl file.
I've read all the documentation I can find. I suggests that I might need to access it some other way (like via the server) but I am unsure of how to d this.

Thanks for all your help trickykid.
 
Old 11-20-2003, 05:39 PM   #8
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
TrickyKid,

Sorry if I pissed you off about the 3 different threads. To me it was a matter of strategy and not a matter of "breaking the rules". You're right, I should have read the rules previously. I won't let it happen again.
 
Old 11-20-2003, 08:49 PM   #9
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
(entered by mistake)

Last edited by jacksmash; 11-21-2003 at 07:37 AM.
 
Old 11-20-2003, 08:50 PM   #10
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
(entered by mistake)

Last edited by jacksmash; 11-21-2003 at 07:38 AM.
 
Old 11-20-2003, 08:53 PM   #11
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
Do I need to give more info than I have? Just tell me what you need to know.

Thanks
 
Old 11-21-2003, 06:12 AM   #12
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
In response to a question re. my httpd.conf file, I am posting some of it here. Please don't laugh if I've messed it up! I'm new at this!!

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<IfModule mod_cgid.c>
#
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
#
Scriptsock run/httpd.cgid
</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
AllowOverride None
Options none
AddHandler cgi-script cgi pl
Order allow,deny
Allow from all
</Directory>


I added the "AddHandler" line. If I need to post more please let me know.

Thanks for all the help!
 
Old 11-21-2003, 07:11 AM   #13
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
What version of apache are we dealing with cause from what you've posted, it should be working afaik.

Any other info would or could help, more httpd.conf if you can, etc.
 
Old 11-21-2003, 07:38 AM   #14
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
I'm not sure which version I'm running! Whatever version that comes with RedHat 9.0 I guess. Is there any way I can do a check to see if it is even running? SOrry if that's a dumb question.


What does "afaik" mean??

Last edited by jacksmash; 11-21-2003 at 07:39 AM.
 
Old 11-21-2003, 09:37 AM   #15
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by jacksmash
I'm not sure which version I'm running! Whatever version that comes with RedHat 9.0 I guess. Is there any way I can do a check to see if it is even running? SOrry if that's a dumb question.


What does "afaik" mean??
AFAIK = As Far As I Know

Umm.. to find your version, just type this at a console or terminal as root:

httpd -V

Oh and easiest way to check and make sure its running would be:

ps -aux | grep httpd
 
  


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
Configuring httpd.conf for CGI in Apache 2.x clinton Linux - Newbie 2 01-01-2005 01:13 AM
configuring cgi-bin in apache gtgoku Linux - General 1 01-19-2004 06:22 AM
Configuring Apache for CGI jacksmash Programming 3 11-20-2003 10:52 PM
configuring apache for cgi scripts ash_r_c Linux - Software 1 09-23-2003 04:03 PM
apache v2.0.44 + cgi ; securing cgi-support in apache markus1982 Linux - General 0 01-20-2003 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:42 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