LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-01-2010, 01:40 AM   #1
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
configuring cgi on ubuntu


when i try to copy this script to the cgi folder, i get an error

casper@casper-laptop:~$ cp /home/casper/hello.cgi /usr/lib/cgi-bin
cp: cannot create regular file `/usr/lib/cgi-bin/hello.cgi': Permission denied
casper@casper-laptop:~$

#!/usr/local/bin/perl
# hello.pl -- my first perl script!
print "Content-type: text/html\n\n";
print <<"EOF";
<HTML>
<HEAD>
<TITLE>Hello, world!</TITLE>
</HEAD>
<BODY>
<H1>Hello, world!</H1>
</BODY>
</HTML>
EOF

i am running apache on ubuntu ibex - is there something that i have to setup to run cgi scripts on ubuntu? it runs ok from the command line - but i want to open it up in a web browser.
 
Old 02-01-2010, 01:44 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Do the cp via sudo

And /usr/local/bin/perl strikes me as an odd location for
perl on Ubuntu. What happened there?


Cheers,
Tink
 
Old 02-01-2010, 10:59 PM   #3
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Original Poster
Rep: Reputation: 16
yeah you are right about the perl path.
i did not copy the file into /usr/lib/cgi-bin yet. - that seems harsh.



I have apache running - but when I run the cgi script is just shows up as plain text in terminal - it does not pop into the browser - lie i thought it would.

I can browse to it from firefox file:///home/casper/hello.cgi - but again it shows up at plain text in the browser, html tags and all.

do all cgi scripts have to go into a cgi-bin folder to work? do i have to configure apache to accept these scripts?
i am trying ot run the script locally on my laptop - not a web server - but i have apache running on the laptop

Last edited by casperdaghost; 02-01-2010 at 11:10 PM.
 
Old 02-02-2010, 12:00 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Yes, they need to be in a directory that is flagged to apache as
part of the cgi path.


Cheers,
Tink
 
Old 02-18-2010, 02:49 PM   #5
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Original Poster
Rep: Reputation: 16
cgi - configuration

I created a new website:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/casperdaghost

Edited the DocumentRoot /home/casper/public_html and the <Directory /home/casper/public_html/> in the new sites configuration fle - the site works great on http://127.0.0.1.

I added a cgi-bin directory to the public_html directory, and edited the ScriptAlias as follows:

ScriptAlias /cgi-bin/ "/home/casper/public_html/cgi-bin/"
<Directory "/home/casper/public_html/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

I chmod cgi script:
-rwxr-xr-x /home/casper/public_html/cgi-bin/testscript.cgi

When browsed in Firefox the script displays the raw html code, not a "Hello, World".

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print <<END_HTML;
<html>
<head></head>
<body>Hello, World!</body>
</html>
END_HTML


I don't know if it is configuration error, or an error in the code. Anybody got any other Apache configuration examples?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help with Apache and Configuring CGI Khadgar Linux - Server 1 08-24-2007 11:07 PM
Configuring Apache for CGI jacksmash Linux - Newbie 18 11-21-2003 02:27 PM
Need help configuring CGI!! jacksmash Programming 6 11-21-2003 07:01 AM
Configuring Apache for CGI jacksmash Programming 3 11-20-2003 11:52 PM
configuring apache for cgi scripts ash_r_c Linux - Software 1 09-23-2003 05:03 PM


All times are GMT -5. The time now is 06:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration