LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-04-2009, 12:36 PM   #1
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Rep: Reputation: 31
Question Instead of executing perl script,Mozilla Firefox opens it,why?


Hello Friends,
The following perl script successfully runs in the terminal:
Quote:
print "Content-type: text/html\n\n";
print "Hello, Hello Testing...!";
but when I run it in the web environment (fedora9, with Apache), it does not executes the script. Instead browser show open with or download message box. Please help me.
 
Old 10-04-2009, 12:43 PM   #2
Stephan_Craft
Member
 
Registered: Jul 2008
Posts: 184

Rep: Reputation: 30
you didn't install php correctly!
remove it, find good tutorial at www.howtoforge.com and you will be fine.
 
Old 10-04-2009, 12:54 PM   #3
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
But I am running the php script files successfully. Only the perl script encounters this problem...
 
Old 10-04-2009, 02:53 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
mq15 you do know that fedora 9 is UNSUPPORTED and has not has a security update in 5 months
 
Old 10-04-2009, 07:04 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
How are you expecting the Perl script to be executed? Is it supposed to be used through CGI or through mod_perl? Do you have the Perl script in a directory configured to use CGI or mod_perl? Do you have these set up correctly in your server config? It sounds like Apache is just displaying it as a normal file, rather than running it as a script.

Also, see John VV's comment about Fedora 9 being out of support.
 
Old 10-05-2009, 12:54 PM   #6
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
OK guys. Immediately after my exam(Oct 10), I will thrust myself to upgrading my fedora9. But at the time please make me do it with whatever I have by telling me how I have to configure the Perl script in a directory to use CGI or mod_perl?

Thanks in advance..
 
Old 10-05-2009, 01:35 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
have you searched the Apache docs for perl ?
http://www.google.com/search?as_q=pe...e.org&safe=off

from above
http://httpd.apache.org/docs/2.2/howto/cgi.html
 
Old 10-05-2009, 09:03 PM   #8
hexahost
LQ Newbie
 
Registered: Oct 2008
Location: Chennai - INDIA
Distribution: CentOS
Posts: 10

Rep: Reputation: 0
install mod_perl and restart apache.
 
Old 10-06-2009, 04:58 AM   #9
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Thanks a lot John VV. From http://httpd.apache.org/docs/2.2/howto/cgi.html I found what was the problem.
1. I was not using:
Quote:
#!/usr/bin/perl
That is to say I was not telling Apache where to find the interpreter for Perl Scripts, and

2. I was saving the .pl files in directory /var/www/myowndirectory/ instead of saving it in /var/www/cgi-bin

What now I get is
Quote:
500 Internal Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
I don't know how to read the error logs..
 
Old 10-06-2009, 12:01 PM   #10
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Friends, please tell the solution or tell me how to read the error log to identify the problem..
 
Old 10-06-2009, 12:19 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
there is a saying about a fish....
...give a fish.... teach to fish.....
 
Old 10-07-2009, 12:53 AM   #12
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
I 100% agree with you John VV and deeply thank you for that. But please give only the HINT at least.
Believe me, if I were not to appear in exam on coming 10th, I would happily hangout with it as long as it would take. But now the problem is of my exam..
 
Old 10-07-2009, 01:36 AM   #13
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
at the moment i am not running an apache server so this is from memory ...
first can you post the part of the apache log when you try to run the script
and
the part of your httpd.conf for the folder that the perl script is in ( cgi-bin AND /var/www both folders)
AND the file permissions of both folders you can get them this way
Code:
cd /var
ls -l
cd www
ls -l
also is mod perl listed in the top of "httpd.conf" .The section near the top where all the mods are.
( mod perl might be built in so it might not be there)
and this ( default )
LoadModule cgi_module modules/mod_cgi.so
this tells me that perl IS working
"The following perl script successfully runs in the terminal:"
so it is apache OR there is one other "SELinux" is there an error in SELinux TroubleShooter ???
it is in the menu under Applacations/systemtools


and i take it that this is at the top of the perl script? " #!/usr/bin/perl "
 
Old 10-07-2009, 09:42 AM   #14
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
I have already shown the apache logs when I try to run the script [in 9th post, 500 Internal Server Error]
Part of httpd.conf for cgi-bin:
Quote:
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#
# "/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
Order allow,deny
Allow from all
</Directory>
Part of httpd.conf for /var/www/:
Quote:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
I did not find any mod perl in the top of httpd.conf
LoadModule:
Quote:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so

#
# The following modules are not loaded by default:
#
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule asis_module modules/mod_asis.so
SELinux does not show any thing for cgi-bin etc
Permissions for /var:
Quote:
[root@localhost var]# cd /var/
[root@localhost var]# ls -l
total 72
drwxr-xr-x 2 root root 4096 2009-04-02 16:58 account
drwxr-xr-x 15 root root 4096 2009-07-26 13:15 cache
drwxr-xr-x 3 root root 4096 2009-04-02 16:58 db
drwxr-xr-x 3 root root 4096 2009-04-02 17:03 empty
drwxr-xr-x 2 root root 4096 2008-04-08 02:44 games
drwxrwx--T 2 root gdm 4096 2008-09-29 21:05 gdm
drwxr-xr-x 37 root root 4096 2009-07-26 13:32 lib
drwxr-xr-x 2 root root 4096 2008-04-08 02:44 local
drwxrwxr-x 5 root lock 4096 2009-10-04 23:57 lock
drwxr-xr-x 17 root root 4096 2009-10-07 20:05 log
lrwxrwxrwx 1 root root 10 2009-04-02 16:56 mail -> spool/mail
drwxr-xr-x 2 root root 4096 2008-04-08 02:44 nis
drwxr-xr-x 2 root root 4096 2008-04-08 02:44 opt
drwxr-xr-x 2 root root 4096 2008-04-08 02:44 preserve
drwxr-xr-x 24 root root 4096 2009-10-08 00:50 run
drwxr-xr-x 13 root root 4096 2009-06-03 06:09 spool
drwxrwxrwt 2 root root 4096 2009-10-07 20:09 tmp
drwxr-xr-x 8 mq15 root 4096 2008-07-15 01:38 www
drwxr-xr-x 3 root root 4096 2008-06-10 19:43 yp
Permissions for /var/www/:

Quote:
[root@localhost var]# cd www/
[root@localhost www]# ls -l
total 24
drwxr-xr-x 2 mq15 root 4096 2009-10-07 20:03 cgi-bin
drwxr-xr-x 3 mq15 root 4096 2009-07-25 09:33 error
drwxr-xr-x 5 mq15 root 4096 2009-10-06 00:03 html
drwxr-xr-x 3 mq15 root 4096 2009-07-25 09:33 icons
drwxr-xr-x 14 mq15 root 4096 2009-07-25 09:33 manual
drwxr-xr-x 2 mq15 root 4096 2009-10-04 23:41 usage
[root@localhost www]#
Also I found the erro_log with entry:


Quote:
[Wed Oct 07 20:11:52 2009] [error] [client 127.0.0.1] (13)Permission denied: exec of '/var/www/cgi-bin/test_perl.pl' failed
[Wed Oct 07 20:11:52 2009] [error] [client 127.0.0.1] Premature end of script headers: test_perl.pl
 
Old 09-09-2010, 08:04 AM   #15
iamyuji
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
I also have the same problem. But I am not running the perl file on my localhost. I run it on a different server and when I try to run it on the browser it opens a download window instead. This is what I have written on my shebang line #!/usr/bin/env perl . I have checked the usr/bin/env of the server and it exists. perl.exe is also there. the server follows linux environment.
 
  


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
Executing Perl Script TalkingMarble Linux - Newbie 4 08-05-2008 08:33 AM
Executing unix commands from perl script running on Windows. harishkrishnan Programming 1 03-04-2008 11:48 PM
executing perl script through .forward file skverma_in Linux - Newbie 3 10-21-2004 07:24 AM
executing perl script through .forward file skverma_in Linux - General 0 10-18-2004 05:06 AM
Unable to open firefox from evolution - always opens Mozilla tog Fedora 1 06-19-2004 12:01 PM

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

All times are GMT -5. The time now is 01:07 AM.

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