LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-06-2010, 04:01 PM   #1
kapshure
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?


Code:
#!/usr/bin/perl

#PERL module
use Mysql;

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

#PERL MYSQL CONNECT
$connect = Mysql->connect($host,$database,$user,$pw);

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


rpm -qa | grep mysql

mysql-5.0.77-4.el5_5.3
mysql-connector-odbc-3.51.26r1127-1.el5
mysql-server-5.0.77-4.el5_5.3
php-mysql-5.1.6-27.el5
mysql-5.0.77-4.el5_5.3
libdbi-dbd-mysql-0.8.1a-1.2.2



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

If I run ./testperl.sh 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


Code:
Perlrequire /etc/httpd/conf/perl-startup.pl
PerlWarn    On
PerlModule  Apache::DBI
I have this in perl-startup.pl

Code:
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 04:04 PM.
 
Old 08-07-2010, 05:30 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,532

Rep: Reputation: 132Reputation: 132
perldoc Apache:BI
perldoc Mysql
everything is in there I guess
 
Old 08-09-2010, 06:30 PM   #3
kapshure
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 test.sh 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, 08:14 PM   #4
kapshure
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)

Code:
#!/usr/bin/perl

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

$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!";
}
$dbh->disconnect();

#########################################

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

this has to be in perl.conf

Code:
LoadModule perl_module modules/mod_perl.so


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

check permissions on your test script, chmod 755 testscript.pl

check from CLI,

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



then run from browser
 
  


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


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