LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-01-2009, 05:28 PM   #1
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Rep: Reputation: 31
Perl support does not work with apache after its installed/configured


Hi

I have a debian 5.0 box with apache2 installed (i used "aptitude install apache2" to install apache2). After i installed apache i also installed libapache-mod-perl2 (i used "aptitude install libapache2-mod-perl2) since im going to be using apache to run perl scripts.

The LoadModule directive was added in the apache configuration as well as the "AddHandler cgi-script cgi pl". The cgi-bin/ directory is already configured with "ExecCGI" and ScriptAlias is set to "ScriptAlias /cgi-bin/ /var/www/cgi-bin".

When i run the following script:
Code:
#!/usr/bin/perl -w
print "Content-type: text/html" ;
print "test" ;
It only shows me a download dialog which i wierd since i have added the mod_perl apache module to apache. I have looked at the error log for apache and it says nothing at all.

The /var/www/cgi-bin directory is owned and readable by the user that is running apache and the perl scripts being run is executable.

I just dont know what more to do here and i would appericiate it if someone could help me out here.

Last edited by exceed1; 05-01-2009 at 06:07 PM.
 
Old 05-01-2009, 05:37 PM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Try

Code:
#!/usr/bin/perl -w
print "Content-type: text/html\n";
print "test";
HTH

Forrest
 
Old 05-01-2009, 05:42 PM   #3
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
I tried it and im still getting the download dialog when typing in http://localhost/cgi-bin/test2.pl

Quote:
Originally Posted by forrestt View Post
Try

Code:
#!/usr/bin/perl -w
print "Content-type: text/html\n";
print "test";
HTH

Forrest
 
Old 05-01-2009, 05:45 PM   #4
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Did you stop and start apache after you made the change?

Forrest
 
Old 05-01-2009, 05:47 PM   #5
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
I stopped and started apache now, no change. I dont understand why i would need to restart apache just because a new script was added, i know its not necessary to do this..but, that said it didnt change anything.

Last edited by exceed1; 05-01-2009 at 05:50 PM.
 
Old 05-01-2009, 06:16 PM   #6
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
OK, I was just thinking that since you are using mod_perl it might be caching the script (forgetting that it would reload it if the file was modified). Anyway, it's been a while since I've done perl web stuff. Anyway, I think I was on the right track initially. But, like I said, it's been a while. You actually need two \n's at the end of your Content-type line, not just one. So, try that and let me know.

Forrest
 
Old 05-01-2009, 06:31 PM   #7
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
Ok, interesting.

I now ran the following script:
Code:
#!/usr/bin/perl -w

print "content-type: text/html \n\n";
print "test";
There were no changes, the download dialog still appeared.
Under the /var/cache/apache2 directory i can see that there is a directory called "mod_disk_cache", but this directory is empty.
I also cleared firefox' cache before i restarted apache and tried to run the script again. I dont know how i would clear mod_perl' cache.
 
Old 05-01-2009, 06:37 PM   #8
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
The space may also be causing a problem. However, it doesn't appear that your server is even trying to run the command. It looks like you are trying to serve it up as a file. You may need to revisit your config.

Forrest
 
Old 05-01-2009, 06:54 PM   #9
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
I tried to run it without the space now, but it didnt change anything. You seem to be correct when you say that apache doesnt even seem to be running the file as a script. The following is shown in the access log when i try to run the file:
127.0.0.1 - - [02/May/2009:01:43:21 +0200] "GET /cgi-bin/test2.pl HTTP/1.1" 200 72 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1)"

I have checked the apache configuration again, but i cant see anything thats missing. It is only the "LoadModule", "AddHandler" that is needed isnt it ? I have the ExecCGI as well but i dont know if this is actually needed when using mod_perl. I have read some articles on the net and searched google, but they only seem to describe what i have done.

I also searched for the mod_perl caching problems and it looked like mod_perl only compiled the code one time, but im not sure about this, and if this is the case, then how would it be cleared or what would be needed to do to re-compile the file again.
 
Old 05-01-2009, 09:22 PM   #10
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Here are the lines from my httpd.conf that I had to modify to get cgi-bin to execute scripts:

556 # ScriptAlias: This controls which directories contain server scripts.
557 # ScriptAliases are essentially the same as Aliases, except that
558 # documents in the realname directory are treated as applications and
559 # run by the server when requested rather than as documents sent to the client.
560 # The same rules about trailing "/" apply to ScriptAlias directives as to
561 # Alias.
562 #
563 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
564
565 #
566 # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
567 # CGI directory exists, if you have that configured.
568 #
569 <Directory "/var/www/cgi-bin">
570 AllowOverride None
571 Options ExecCGI
572 Order allow,deny
573 Allow from all
574 </Directory>

HTH

Forrest

p.s. The numbers are just line numbers.
 
Old 05-02-2009, 05:50 AM   #11
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
Thanks for answering forrestt. I already have this configuration present in apache, thats what makes it so wierd that it doesnt work. I cant imagine what it can be. Ill continue to search the net, and read in my apache book to try to figure out whats actually happening here. Please do reply if you have any more ideas
 
Old 05-02-2009, 10:24 AM   #12
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Original Poster
Rep: Reputation: 31
I downloaded, compiled and installed Apache 2 and then added mod_perl2 through the CPAN shell. And after adding the "LoadModule" line to the apache config. the perl scripts worked. I dont have any logical explanation to why debian' specific apache configuration didnt work though.
 
  


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
i installed fc4 wnad my apache should have been configured to handle php file but it' amolgupta Linux - Software 2 04-02-2006 11:22 AM
Getting Perl to work with Apache N4MtRaC Linux - Software 1 07-12-2005 01:00 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
Installed Xfree 4.3.0, configured, but it still doesn't work enigma Z Linux - General 2 09-24-2003 08:41 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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