Installing CGI
Hi,
I just installed RedHat 9 about 2 days ago and don't think I've done too badly, considering I'm a newbie. I've got a samber and apache running pretty quick. Now, I want my server (the computer I'm talkin about) to display CGI files. When I type url-here.com/cgi-bin/file.cgi I get a "Page cannot be displayed error". Does this mean I need to install ActivePerl? If so, I've downloaded ActivePerl, where do I go from here? I installed ActivePerl when I had my win2k server, which was reasonably simple since it's mostly GUI. Can anyone tell me how to install ActivePerl on RedHat 9, or, does anyone have any simple language tutorials I can look at? Thanks in advanced. Oh, btw, it's weird, because PHP works on my server fine and I didn't even attempt to install that. |
I doubt if you need active perl. Do you get an error number ie "500 server error"?
What are the permissions on the file? Is it executable by the apache user? You may get more information from the apache error_log file. |
Checked the error log, it says:
[Sun Jul 27 21:51:52 2004] [error] [client xxx.xx.0.2] script not found or unable to stat: /var/www/cgi-bin/gm.cgi |
Can you post the output from:
ls -l /var/www/cgi-bin |
Sure thing..
total 700 -rw-rw-rw- 1 moor moor 52 Jun 27 16:44 gm-authors.cgi -rw-r--r-- 1 moor moor 23 Jun 27 16:43 gm-banlist.cgi -rw-r--r-- 1 moor moor 7275 Jun 27 16:28 gm.cgi -rw-r--r-- 1 moor moor 19127 Jun 27 16:25 gm-comments.cgi -rw-r--r-- 1 moor moor 400 Jun 27 16:43 gm-config.cgi -rw-r--r-- 1 moor moor 16 Jun 27 19:33 gm-counter.cgi -rw-r--r-- 1 moor moor 3859 Jun 27 19:33 gm-cplog.cgi -rw-r--r-- 1 moor moor 37 Jun 27 16:44 gm-entrylist.cgi -rw-r--r-- 1 moor moor 10295 Jun 27 16:25 gm-karma.cgi -rw-r--r-- 1 moor moor 606982 Jun 27 16:28 gm-library.cgi -rw-r--r-- 1 moor moor 22522 Jun 27 19:33 gm-templates.cgi -rw-r--r-- 1 moor moor 9162 Jun 27 16:28 gm-upload.cgi |
You will need to set the execute bit so that apache can run the files - try either:
chmod -R 755 /var/www/cgi-bin Or for more security: chmod -R 750 /var/www/cgi-bin chgrp -R apache /var/www/cgi-bin That assumes that apache is running as apache and not another user. |
Still not working. :(
|
Is it the same error in the error_log? Can you post the output from:
ls -la /var/www/cgi-bin ps -ef | grep apache |
Do you get an error number ie "500 server error"?
Yes I do, sorry, I missed that before. |
ls -la /var/www/cgi-bin:
total 708 drwxr-xr-x 2 root root 4096 Jun 28 07:29 . drwxrwxrwx 9 root root 4096 Jun 27 23:37 .. -rwxr-xr-x 1 moor apache 52 Jun 27 16:44 gm-authors.cgi -rwxr-xr-x 1 moor apache 23 Jun 27 16:43 gm-banlist.cgi -rwxr-xr-x 1 moor apache 7275 Jun 27 16:28 gm.cgi -rwxr-xr-x 1 moor apache 19127 Jun 27 16:25 gm-comments.cgi -rwxr-xr-x 1 moor apache 400 Jun 27 16:43 gm-config.cgi -rwxr-xr-x 1 moor apache 16 Jun 27 19:33 gm-counter.cgi -rwxr-xr-x 1 moor apache 3859 Jun 27 19:33 gm-cplog.cgi -rwxr-xr-x 1 moor apache 37 Jun 27 16:44 gm-entrylist.cgi -rwxr-xr-x 1 moor apache 10295 Jun 27 16:25 gm-karma.cgi -rwxr-xr-x 1 moor apache 606982 Jun 27 16:28 gm-library.cgi -rwxr-xr-x 1 moor apache 22522 Jun 27 19:33 gm-templates.cgi -rwxr-xr-x 1 moor apache 9162 Jun 27 16:28 gm-upload.cgi ps -ef | grep apache: apache 2789 2152 0 Jun27 ? 00:00:00 [httpd] apache 2790 2152 0 Jun27 ? 00:00:00 [httpd] apache 2791 2152 0 Jun27 ? 00:00:00 [httpd] apache 2792 2152 0 Jun27 ? 00:00:00 [httpd] apache 2793 2152 0 Jun27 ? 00:00:00 [httpd] apache 2794 2152 0 Jun27 ? 00:00:00 [httpd] apache 2795 2152 0 Jun27 ? 00:00:00 [httpd] apache 2796 2152 0 Jun27 ? 00:00:00 [httpd] root 8375 2101 0 07:40 pts/0 00:00:00 grep apache and I'm getting this error in error log: Mon Jun 28 07:32:00 2004] [error] [client 203.18.0.2] Premature end of script headers: gm.cgi [Mon Jun 28 07:32:00 2004] [error] [client 203.18.0.2] Can't locate CGI/Carp.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at /var/www/cgi-bin/gm.cgi line 18. [Mon Jun 28 07:32:00 2004] [error] [client 203.18.0.2] BEGIN failed--compilation aborted at /var/www/cgi-bin/gm.cgi line 18. |
Well you are getting there :) The scripts are now being run but is looking for "CGI/Carp.pm" perl module which is not on your system. You should be able to install it with CPAN:
perl -eshell -MCPAN If this is the first time you have used it you will need to go through the config - the defaults should be fine. Then install Carp with: install CGI::Carp |
I typed perl -eshell -MCPAN and got the following:
Can't locate CPAN.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thr ead-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread- multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/ven dor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib /perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5 .8.0 .). |
Welll you can either install cpan which will make it easier to install perl modules in the future or just install the Carp module manually. Either way you can get the source from:
http://www.cpan.org |
Ok, I'll do that when I get home in about 5 hours. :P
I'm a little confused though, what do I exactly have to do? I'm very sorry, my newbness is taking over me. :( |
You need to do exactly what david_ross told you to do. What is happening is that Apache is trying to execute your CGI script. It is not able to do so, however, because a Perl module that your script uses is not installed on your system. When you launch the CPAN shell (which is what perl -MCPAN -eshell does) you will be given a prompt. You can then type the install command that david_ross gave you, which will download and install that module. This may seem strange if you're unfamiliar with Perl, but it'll become more familiar with time.
|
All times are GMT -5. The time now is 03:56 PM. |