CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How to Perl CGI script in apache web sever

 



rammohan
Novice

Feb 25, 2014, 5:17 AM

Post #1 of 7 (1793 views)
How to Perl CGI script in apache web sever Can't Post

I'm learning Perl . Currently I'm learning Perl CGI script,in this script i wrote one sample hello world program

Code
    #!/usr/bin/perl -w 
# hello.pl -- my first perl script!
print "Content-type: text/html\n\n";
print "Hello, world!\n";

I saved above script in /usr/local/apache2/cgi-bin/hello.pl
For this I installed apache web server in my machine, I checked this web server by using http://localhost it works fine. Then i run my hello.pl program in my browser by using apache server

http://localhost/cgi-bin/hello.pl

but above url showing error.

Code
    Not Found 

The requested URL /cgi-bin/hello.pl was not found on this server.

Apache/2.2.15 (CentOS) Server at localhost Port 80


why it showing this. Is there any thing wong in script or in apache? Did any one face this problem? Please let me know,try to resolve this problem

Code
I also attached httpd.conf file



(This post was edited by rammohan on Feb 25, 2014, 9:12 PM)
Attachments: httpd.conf (13.3 KB)


FishMonger
Veteran / Moderator

Feb 25, 2014, 6:52 AM

Post #2 of 7 (1787 views)
Re: [rammohan] How to Perl CGI script in apache web sever [In reply to] Can't Post

Why did you start a new thread for this issue when we were working on it in your prior thread?

Please post the output of these commands:

Code
ls -l /usr/local/apache2/cgi-bin/hello.pl


Code
cat /usr/local/apache2/cgi-bin/hello.pl


Code
/usr/bin/od -c /usr/local/apache2/cgi-bin/hello.pl

Use the code tags around the output to retain the formatting.

Run your script from the command line and post the output.

Restart apache then run the script from the browser and post the complete error message from the web server error log.

Post the complete httpd.conf file as an attachment.


rammohan
Novice

Feb 25, 2014, 9:03 PM

Post #3 of 7 (1761 views)
Re: [FishMonger] How to Perl CGI script in apache web sever [In reply to] Can't Post

your codes showing following output

Code
[Admin@localhost ~]$ ls -l /usr/local/apache2/cgi-bin/hello.pl 
-rwxr-xr-x. 1 root root 120 Feb 25 16:31 /usr/local/apache2/cgi-bin/hello.pl
[Admin@localhost ~]$ cat /usr/local/apache2/cgi-bin/hello.pl
#!/usr/bin/perl -w
#hello.pl -- my first perl script!
print "Content-type: text/html\n\n";
print "Hello, world!\n";



[Admin@localhost ~]$ /usr/bin/od -c /usr/local/apache2/cgi-bin/hello.pl
0000000 # ! / u s r / b i n / p e r l
0000020 - w \n # h e l l o . p l - -
0000040 m y f i r s t p e r l s
0000060 c r i p t ! \n p r i n t " C o
0000100 n t e n t - t y p e : t e x t
0000120 / h t m l \ n \ n " ; \n p r i n
0000140 t " H e l l o , w o r l d !
0000160 \ n " ; \n \n \n \n
0000170
[Admin@localhost ~]$



rammohan
Novice

Feb 25, 2014, 9:10 PM

Post #4 of 7 (1756 views)
Re: [FishMonger] How to Perl CGI script in apache web sever [In reply to] Can't Post

I also attached screen shot after running my url in browser.. I did all the steps what u said.. still same error
Attachments: Screenshot.png (53.7 KB)


rammohan
Novice

Feb 25, 2014, 9:20 PM

Post #5 of 7 (1752 views)
Re: [FishMonger] How to Perl CGI script in apache web sever [In reply to] Can't Post

this program in running well in terminal

Code
[Admin@localhost cgi-bin]$ perl hello.pl  
Content-type: text/html

Hello, world!


Please see attached screen shot and attached file.


(This post was edited by rammohan on Feb 25, 2014, 9:22 PM)
Attachments: httpd.conf (13.3 KB)
  Screenshot.png (53.7 KB)


FishMonger
Veteran / Moderator

Feb 26, 2014, 6:18 AM

Post #6 of 7 (1725 views)
Re: [rammohan] How to Perl CGI script in apache web sever [In reply to] Can't Post

What is the exact error message reported in the log file?
/etc/httpd/logs/error_log


rammohan
Novice

Feb 27, 2014, 4:11 AM

Post #7 of 7 (1694 views)
Re: [FishMonger] How to Perl CGI script in apache web sever [In reply to] Can't Post

Thank you achieved my goal

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives