Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-01-2006, 01:40 PM   #1
Registered: Jan 2006
Distribution: Debian Sarge
Posts: 265

Rep: Reputation: 30
executing perl cgi

I am wanting to start using cgi in perl, but everytime I run it, it just gives me a printout of the html data.
Old 02-01-2006, 08:13 PM   #2
LQ Newbie
Registered: Jan 2006
Distribution: Slackware 9.1
Posts: 23

Rep: Reputation: 15
That's what it's supposed to do, right? You need to enter the URL of the cgi file in your web browser to see the HTML page generated by hte CGI script. And the CGI file should be in the cgi-bin folder of your DocumentRoot which generally is /var/www/html/cgi-bin or /var/www/htdocs/cgi-bin. Then start your webserver and put the URL of the cgi script -
Old 02-02-2006, 07:17 PM   #3
LQ Newbie
Registered: Apr 2005
Distribution: SuSE Linux 9.3 (opensuse)
Posts: 19

Rep: Reputation: 0
For your web browser to notice that the file should be executed instead of just sent over the web you need to make it executable and give it a proper extension. To make it executable, place the script in the cgi-bin directory and chmod a+x scriptfile
The extension (eg .cgi) depends on your httpd.conf

Check your httpd.conf file:
First of all, you need to add a directory directive for the cgi-bin directory, for instance:
<Directory "/srv/www/cgi-bin">
Options ExecCGI
AddHandler cgi-script .cgi .pl

order allow,deny
allow from all

should your scripts be placed in /srv/www/cgi-bin.
Giving it cgiexec permission you allow script execution from that directory (/srv/www/cgi-bin en this example); the AddHandler line just tells apache to consider executable files those which end with .cgi and .pl (you can put what ever extension you like here, your script files must end with any one of this extensions).
Finally, I added an allow from all so anyone could access the script.

You also need to specify which directories contain server scripts, to do this just edit the line ScriptAlias (also in httpd.conf) to point to where you placed the cgi executable, in this example it would be something like:

ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

so, when someone types in his browser, apache will know he's refering to /srv/www/cgi-bin

Hope you find it useful.
Old 02-03-2006, 01:12 AM   #4
Registered: Jan 2006
Distribution: Debian Sarge
Posts: 265

Original Poster
Rep: Reputation: 30
thanks for the help.
Old 09-21-2006, 07:54 PM   #5
LQ Newbie
Registered: Dec 2000
Location: Hattiesburg ms
Posts: 26

Rep: Reputation: 15
Having similar problems

I can't get my scripts to execute outside of the directory and everytime I try to navigate to the directory it tells me it is not found. So I made a sym link to the directory and it tells me I do not have permission. So I made the whole damn thing 777 leaving it open to anyone and it still tells me I do not have permission. So I made apache run as root, it still tells me I do not have permission. I am all out of ideas here. Anybody got any suggestions?


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
CGI Scripts not executing, pls help john_d13 Linux - General 3 12-22-2004 03:05 PM
CGI File Not Executing on Apache Server kaplan71 Linux - Software 2 10-21-2004 08:12 AM
Executing from cgi theonebeyond Programming 4 10-05-2004 12:30 AM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 06:07 AM
Executing a program on server using CGi/PERl ?! avios Red Hat 1 12-29-2003 03:34 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration