Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Perl and Mysql logs

by PierreForget (Acolyte)
on Mar 18, 2013 at 23:09 UTC ( [id://1024172]=perlquestion: print w/replies, xml ) Need Help??

PierreForget has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I am reinstalling a web server for the n'th time and as usual, all the software have change paramaters and use. Which I understand, for the sake of security and ease of use (Ha!Ha!...)

Installation is Slackware 14.0 with Perl 5.16.1, Apache 2.4.3 (with suexec functional), vhost, and all under a chroot (under /httpd).

I use the Perl install from Slackware, reinstalled Apache, sendmail, etc.

I have a hard core preference for Slackware, because I prefer to install and see what is happening. I am not very found of Yum types of installs. I know it's convenient for other people (and I use it on Centos machines), but I prefer the old way...

I need to see the logs in each of the vhost logs and Apache is doing it for me correctly. Example: Logs go to: /httpd/domainname/logs/error_log

If I use a Perl script (with a voluntary error), which is in a vhost, directly from the command line as root, I get the normal error log (this is what I need):

DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field list' at /httpd/domainname/cgi/testerreur.pl line 22.

If I do it from a browser, I see no error message from the same script in the logs of the vhost. Although, if I make a Perl critical error, I get:

[Mon Mar 18 13:40:36.217614 2013] [cgid:error] [pid 27555:tid 2855271232] [client xxx.xxx.245.237:49669] End of script output before headers: testerreur.pl

My other servers behave correctly, but they are running with older versions of all the software.

Pretty difficult to debug Mysql when you don't have logs. For me, logs is everything...

Please note that I am using the -w switch in the Perl script. I also tried use warnings:, but to no avail.

I made sure that all the libraries are under the chroot.

Results of ldd

linux-gate.so.1 (0xffffe000) libperl.so => /usr/lib/perl5/CORE/libperl.so (0xb75f6000) libnsl.so.1 => /lib/libnsl.so.1 (0xb75c3000) libdl.so.2 => /lib/libdl.so.2 (0xb75be000) libm.so.6 => /lib/libm.so.6 (0xb7592000) libcrypt.so.1 => /lib/libcrypt.so.1 (0xb755e000) libutil.so.1 => /lib/libutil.so.1 (0xb755a000) libpthread.so.0 => /lib/libpthread.so.0 (0xb7540000) libc.so.6 => /lib/libc.so.6 (0xb73bb000) /lib/ld-linux.so.2 (0xb777d000)

Library folders as root

/usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5

Library folders as chroot

/httpd/usr/local/lib/perl5 /httpd/usr/local/share/perl5 /httpd/usr/lib/perl5/vendor_perl /httpd/usr/share/perl5/vendor_perl /httpd/usr/lib/perl5 /httpd/usr/share/perl5

If I make chroot /httpd /usr/bin/instmodsh, I get 64 modules installed. If I make /usr/bin/instmodsh, I get 209 modules installed. Am I missing something here?

I usually find it by myself, but I've been searching the Internet and didn't find anything valuable. Any idea where I can start searching?

Thank you

Replies are listed 'Best First'.
Re: Perl and Mysql logs
by kielstirling (Scribe) on Mar 19, 2013 at 04:01 UTC
    Look at line 22 in the script /httpd/domainname/cgi/testerreur.pl and see what SQL it is running.
    Seems like the columns in the database have changed.
    Connected to mysql and desc the table to see if clientpreno exists
    -Kiel

      Hi and thank you for the reply.

      The clientpreno is a voluntary mistake, so that the system will generate a Mysql error. Otherwise, the Perl script gets executed without generating any error. The purpose is to be able to get Mysql errors when there is an error in the code. Actually, I am not able to debug the Mysql code in Perl, because it doesn't generate any Mysql error when the script is called from a browser. If it's called from root, I get the Mysql error. If it's called from root with a chroot, I still get the error.

      Called from root:

      perl /httpd/domainname/cgi/testerreur.pl DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field +list' at /httpd/domainname/cgi/testerreur.pl line 22.

      Called from root with a chroot:

      chroot /httpd perl /httpd/domainname/cgi/testerreur.pl DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field +list' at /httpd/domainname/cgi/testerreur.pl line 22.

      Called from a browser (results from the Apache logs):

      No errors in the logs and the page is shown in the browser.

      Just like I said in the previous post, if I make a Perl error, I get the usual "Premature end of script headers".

      Thanks

        Hi, I found something new.

        I finally found where Apache is sending the Mysql logs. It is sending it directly to the main Apache logs, instead of the local vhost logs, although the directive in httpd.conf is local:

        Errorlog "/httpd/restaurant-quebec/logs/error_log"

        Here is the log in /httpd/usr/local/apache2/logs

        DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field +list' at testerreur.pl line 22.

        So, it's not a Perl problem, but an Apache problem. I will continue my search and I will post the results once I find the issue, so that people who search for the same problem will have a solution.

        Thanks to everybody who took the time to read and reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1024172]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found