LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-14-2010, 11:57 AM   #1
Leslie007
LQ Newbie
 
Registered: Sep 2009
Posts: 8

Rep: Reputation: 2
Perl cgi configuration under apache2


Dear friends,

I want to learn perl CGI. I tried to configure it on apache server.
But when I was searching about it in the net, I faced some difficulties.
Each and every post has been leaded me in different way. I am confused now.

I have done this,

1. Installed this libapache2-mod-perl2 module

2. Then I checked the /etc/apache2/mods-available/ using ls command
for checking the module availability. Here I mentioned the output of ls command.

$ ls -lrt perl*
rw-r--r-- 1 root root 60 2010-02-03 23:41 perl.load

$ ls -lrt cgi*

-rw-r--r-- 1 root root 58 2010-04-14 00:57 cgi.load
-rw-r--r-- 1 root root 60 2010-04-14 00:57 cgid.load
-rw-r--r-- 1 root root 68 2010-04-14 00:57 cgid.conf

3. I Checked the /etc/apache2/mods-enabled using ls command for checking the module availability. Here I mentioned the output of ls command.

$ ls -lrt perl*

lrwxrwxrwx 1 root root 27 2010-09-13 23:12 perl.load ->../mods-available/perl.load

$ls -lrt cgi*

lrwxrwxrwx 1 root root 26 2010-07-16 00:16 cgi.load -> ../mods-available/cgi.load

4. Edited the /etc/apache2/sites-available/default file and added this some lines. Now my file contains these below data.

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /home/somebody/public_html/cgi-bin/
<Directory "/home/somebody/public_html/cgi-bin/">
AllowOverride None
Options ExecCGI
AddHandler cgi-script cgi pl
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


5. under /var/www/ I have created symbolic link to my home dir for php application development. Here I mentioned the output of ls command,

$ ls -lrt

lrwxrwxrwx 1 root root 25 2010-07-16 18:15 public_html -> /home/somebody/public_html/

6. I have created the cgi-bin directory under /home/somebody/public_html/

7. Restarted the apache server

8. created the cgi script with 755 permission under /home/somebody/public_html/cgi-bin dir. Then I have executed it. Browser just printed the file content as it is. I have changed the file extension from .cgi to .pl . While executing this .pl file, its just downloaded the file instead of executing and printing the output on browser.

9. So I have copied same /etc/apache2/sites-available/default content into /etc/apache2/httpd.conf file, and restarted the apache server. Now I tried to execute the same cgi script which is there in my home directory.
Now also I failed in this.


System configuration:

OS => ubuntu 10.4
Browser => firefox 3.6.3

I want to create and execute the cgi script from my home.
Can any one plzz help me to solve this issue. I am trying to solve this issue last 5 days. plzz help me.

Thanks frds..
 
Old 09-14-2010, 04:15 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Your script alias line should have the path quoted
Code:
ScriptAlias /cgi-bin/ "/home/somebody/public_html/cgi-bin/"
Also, the <directory> line should not have a trailing slash.
Code:
<Directory "/home/somebody/public_html/cgi-bin">
Also, the AddHandler line should really be with the other AddHandler lines in httpd.conf.
You don't need the Options ExecCGI in the script alias directory, as it is designed for running scripts from anyway. Also, it is good practice to place the cgi-bin outside the document root for security, i.e. in /home/somebody/

Personally, I always create a www directory, with a cgi-bin and an html directory inside. The www/html is then defined as the document root, and the whole site is self contained.

i.e.

/home/smoker/my-site/www/html
/home/smoker/my-site/www/cgi-bin

Finally, you don't actually have to use mod_perl when running a cgi-script. mod_perl scripts have to be specified in httpd.conf for them to work.
http://perl.apache.org/start/tips/registry.html

Last edited by smoker; 09-14-2010 at 04:19 PM.
 
Old 09-15-2010, 01:06 PM   #3
Leslie007
LQ Newbie
 
Registered: Sep 2009
Posts: 8

Original Poster
Rep: Reputation: 2
Thank u frds.. I have configured successfully..
 
  


Reply



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
Apache2 cgi-bin perl - My browser just wants to download the .pl files keenboy Linux - Server 4 05-19-2010 09:42 AM
problem getting perl working with apache2 cgi script jabberwok Linux - Server 10 04-17-2009 08:30 AM
LXer: How to Install Apache2 webserver with PHP,CGI and Perl Support in Ubuntu Server LXer Syndicated Linux News 0 10-17-2008 06:10 PM
Apache2 on Debian won't execute perl cgi scripts, have tried chmod, Options ExecCGI dewert Linux - Software 1 07-03-2006 12:44 PM
Apache2 CGI-Perl will not read files fefeh Linux - Software 0 06-30-2003 08:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

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
Open Source Consulting | Domain Registration