Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-06-2010, 03:01 PM   #1
LQ Newbie
Registered: Mar 2010
Posts: 29

Rep: Reputation: 1
whats proper way to test login to mysql via mod_perl

would this script not work?


#PERL module
use Mysql;

$host = "localhost";
$database = "salon";
$user = "root";
$pw = "salontest";

$connect = Mysql->connect($host,$database,$user,$pw);

This is perl, v5.8.8 built for x86_64-linux-thread-multi
CentOS 5.5 x86_64

rpm -qa | grep mysql


should I be able to just execute http://localhost/ from browser?

If I run ./ then I get nothing on CLI.. I echo exist status and get a "0"

sorry for all the newb questions, I clearly have a lot to learn, but I have done about 10 Google searches trying to find out how to test connectivity b/t mod_perl and mysql.. maybe I'm confused on how this works. Any clarification is greatly appreciated.

I have this in httpd.conf

Perlrequire /etc/httpd/conf/
PerlWarn    On
PerlModule  Apache::DBI
I have this in

use Apache::Registry; # =>  For stuff in "/perl" location
use Apache::Status;   # =>  For "/perl-status"
use Apache::DBI;      # =>  Persistent DB Connections

Last edited by kapshure; 08-06-2010 at 03:04 PM.
Old 08-07-2010, 04:30 AM   #2
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,585

Rep: Reputation: 145Reputation: 145
perldoc Apache:BI
perldoc Mysql
everything is in there I guess
Old 08-09-2010, 05:30 PM   #3
LQ Newbie
Registered: Mar 2010
Posts: 29

Original Poster
Rep: Reputation: 1
great. thanks so much for that. I do feel retarded for not having known to look there in "perldoc"

but my other question is - I think from what I've been told is that I'm trying to test the mod_perl functionality in apache - so wouldnt I have to make the script an executable? seems that this perldoc:Mysql just covers from the CLI and configuration parameters in httpd.conf for Apache::DBI --- how exactly do I perform the test? Initially, I was under the impression I would just call up the or test.exe from the browser, but this just downloads it. how do I actually test the connection via mod_perl to mysql
Old 08-09-2010, 07:14 PM   #4
LQ Newbie
Registered: Mar 2010
Posts: 29

Original Poster
Rep: Reputation: 1
OK, I actually got this to work

here is a script to not only test mod_perl > mysql, but also mod_perl > pgsql (in case someone else stumbles across this thread and needs a quick concise script)


use DBI;
$dbname = 'postgres';
$host = 'localhost';
$port = '5432';
$username = 'postgres';
$password = 'test';
$dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;options=$options",
                      {AutoCommit => 0, RaiseError => 1, PrintError => 0}
if ( not $dbh ) {
warn "No connection to postgres!!";
} else {
warn "Connection to postgres!";

$dbname = 'mysql';
$host = 'localhost';
$username = 'root';
$password = 'root';
$dbh = DBI->connect("DBI:mysql:database=$dbname;host=$host",
                         $username, $password,
                         {'RaiseError' => 1});
if ( not $dbh ) {
warn "No connection to mysql!!";
} else {
warn "Connection to mysql!";


ExecCGI has to be in the in the directive container for /var/www/DocumentRoot

this has to be in perl.conf

LoadModule perl_module modules/

Alias /perl /var/www/html
<Directory /var/www/html>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI

check permissions on your test script, chmod 755

check from CLI,

[root@CentOS-test html]# perl -l
Connection to postgres! at line 18.
Connection to mysql! at line 32.

then run from browser


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
LXer: Farmer gives low-cost laptop a proper field test LXer Syndicated Linux News 0 02-13-2008 11:10 AM
mod_perl with Slack11 / php4.4 /Apache 1.3.37/mysql 5 bgeddy Slackware 4 01-23-2007 11:30 AM
whats the Proper way ? Daunted Linux - Hardware 0 10-04-2004 04:01 PM
Whats the difference between Fedora 2 test releases and final version? MSA Fedora 1 05-20-2004 06:22 PM
MySQL / phpMyAdmin - Can only see test table after granting proper privelages.. Transition Linux - Software 2 02-03-2004 12:45 PM > Forums > Linux Forums > Linux - Newbie

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