Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Perl and Mysql logs

by PierreForget (Novice)
on Mar 18, 2013 at 23:09 UTC ( #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/ 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] End of script output before headers:

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 (0xffffe000) => /usr/lib/perl5/CORE/ (0xb75f6000) => /lib/ (0xb75c3000) => /lib/ (0xb75be000) => /lib/ (0xb7592000) => /lib/ (0xb755e000) => /lib/ (0xb755a000) => /lib/ (0xb7540000) => /lib/ (0xb73bb000) /lib/ (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/ 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

      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/ DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field +list' at /httpd/domainname/cgi/ line 22.

      Called from root with a chroot:

      chroot /httpd perl /httpd/domainname/cgi/ DBD::mysql::st execute failed: Unknown column 'clientpreno' in 'field +list' at /httpd/domainname/cgi/ 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".


        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 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1024172]
Approved by kcott
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2018-06-18 19:26 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (110 votes). Check out past polls.