LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Instead of executing perl script,Mozilla Firefox opens it,why? (https://www.linuxquestions.org/questions/linux-server-73/instead-of-executing-perl-script-mozilla-firefox-opens-it-why-759634/)

mq15 10-04-2009 12:36 PM

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.

Stephan_Craft 10-04-2009 12:43 PM

you didn't install php correctly!
remove it, find good tutorial at www.howtoforge.com and you will be fine.

mq15 10-04-2009 12:54 PM

But I am running the php script files successfully. Only the perl script encounters this problem...

John VV 10-04-2009 02:53 PM

mq15 you do know that fedora 9 is UNSUPPORTED and has not has a security update in 5 months

btmiller 10-04-2009 07:04 PM

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.

mq15 10-05-2009 12:54 PM

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?
:newbie:
Thanks in advance..

John VV 10-05-2009 01:35 PM

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

hexahost 10-05-2009 09:03 PM

install mod_perl and restart apache.

mq15 10-06-2009 04:58 AM

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..:banghead:

mq15 10-06-2009 12:01 PM

Friends, please tell the solution or tell me how to read the error log to identify the problem..

John VV 10-06-2009 12:19 PM

there is a saying about a fish....
...give a fish.... teach to fish.....

mq15 10-07-2009 12:53 AM

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..

John VV 10-07-2009 01:36 AM

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 "

mq15 10-07-2009 09:42 AM

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

iamyuji 09-09-2010 08:04 AM

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.


All times are GMT -5. The time now is 03:34 PM.