[MP2] Placing Apache::RequestRec Apache::RequestIO APR::Tableuse statements in startup.pl
Will placing Apache::RequestRec Apache::RequestIO APR::Table in startup.pl to load them up for multiple handlers have any bad side effects? I noticed that when I load them via startup.pl the handlers that use them don't complain that they don't have the use statements within the module code and still work as normal. Jamie Krasnoo
Re: [MP2] Placing Apache::RequestRec Apache::RequestIO APR::Table use statements in startup.pl
On Thu, 2003-07-24 at 02:15, Stas Bekman wrote: Jamie Krasnoo wrote: Will placing Apache::RequestRec Apache::RequestIO APR::Table in startup.pl to load them up for multiple handlers have any bad side effects? I noticed that when I load them via startup.pl the handlers that use them don't complain that they don't have the use statements within the module code and still work as normal. While this works for you, it's a bad practice. Why? Because other people using your code may not have these modules loaded from startup.pl. Won't loading them for every handler put an instance of it in memory over and over again though? Or will Perl realize that its already loaded and not load it again? How would this behave in MPM threadpool? Jamie
Re: MP2 Redirection
On Tue, 2003-07-22 at 02:50, Stas Bekman wrote: Jamie Krasnoo wrote: What would be the best way to redirect in MP2? How would I set the Location in the header? not any different from mp1 (assuming that you have been working with mp1 before, but the mp1 documentation and literature can be used as a reference for most mp2 things). something like this? my $r = Apache-request; # docs say $r-header_out and family are now deceased. that's right. And $r-headers_out() is available in mp1 for several years and should be used in mp1 as well to easy the transition. $r-headers_out(Location = '/some/place.html'); return Apache::DECLINED; why DECLINED? just return Apache::OK. My mistake, its been a while and I'm just getting back into it. So its like I'm learning everything all over again. You can use OK? The example in the Eagle book uses REDIRECT within a handler for redirection. So I'm assuming it goes the same for MP2. I'm also not sure why do you use Apache-request, I assume you are inside a handler, not a registry script. Since if you are inside a registry script you don't need to return anything at all. I was using Apache-request as an example. I guess it's a poor one. I should have just used 'my $r = shift;' to get the point across. Jamie Krasnoo
Re: MP2 Redirection
On Tue, 2003-07-22 at 03:10, Jamie Krasnoo wrote: On Tue, 2003-07-22 at 02:50, Stas Bekman wrote: Jamie Krasnoo wrote: What would be the best way to redirect in MP2? How would I set the Location in the header? not any different from mp1 (assuming that you have been working with mp1 before, but the mp1 documentation and literature can be used as a reference for most mp2 things). something like this? my $r = Apache-request; # docs say $r-header_out and family are now deceased. that's right. And $r-headers_out() is available in mp1 for several years and should be used in mp1 as well to easy the transition. $r-headers_out(Location = '/some/place.html'); return Apache::DECLINED; why DECLINED? just return Apache::OK. My mistake, its been a while and I'm just getting back into it. So its like I'm learning everything all over again. You can use OK? The example in the Eagle book uses REDIRECT within a handler for redirection. So I'm assuming it goes the same for MP2. I'm also not sure why do you use Apache-request, I assume you are inside a handler, not a registry script. Since if you are inside a registry script you don't need to return anything at all. I was using Apache-request as an example. I guess it's a poor one. I should have just used 'my $r = shift;' to get the point across. I got the redirection to work. However I don't think its working as it should. Nowhere in the docs does it say that you have to load APR::Table with Apache::RequestRec and Apache::RequestIO to have $r-headers_out() to work. Without APR::Table loaded I get the error: [Tue Jul 22 03:56:35 2003] [error] [client 192.168.0.2] Can't locate object method STORE via package APR::Table at /www/web/perl/MyApache/Redirect.pm line 17. Place APR::Table in and the error goes away. Here's a sample script below. Jamie Krasnoo package MyApache::Redirect; use strict; use warnings; use Apache::RequestRec; use Apache::RequestIO; # comment out 'use APR::Table;' to get error, uncomment to make it go # away. # use APR::Table; use Apache::Const -compile = qw(REDIRECT); sub handler { my $r = shift; $r-content_type('text/html'); $r-headers_out-{Location} = 'http://www.yahoo.com/'; return Apache::REDIRECT; } 1;
MP2 Redirection
What would be the best way to redirect in MP2? How would I set the Location in the header? something like this? my $r = Apache-request; # docs say $r-header_out and family are now deceased. $r-headers_out(Location = '/some/place.html'); return Apache::DECLINED; Jamie Krasnoo
mod_perl 2.0 and cookies
So Ive decided to dive headlong into 2.0. So far I like it but find the documentation lacking and there seems to be a lot missing. I tried Apache::Cookie with it, no dice. It gave an error to the effect that it didnt know what bootstrap was (I think that was it). Apache::Cookie made inserting cookies in mod_perl 1.0 so easy which in turn made life easier for programming. However I have scoured the documentation on how to insert a cookie into the header and the only thing I could come up with is that you use a filter to do it. Somehow I dont think that this is right and I am completely off. Could someone enlighten me as to how cookies work in MP2? If I can get past this I can figure out the rest on my own and maybe write a little documentation if I can understand it enough to do so. Thank you, Jamie
mod_perl 1.0 and 2.0
Hi all, Im currently working on a personal project to get myself back in mod_perl programming order. However Im more used to using mod_perl 1.0 with Apache 1.3.x. Im going through the documentation for mod_perl 2.0 but Im worried that most of the modules I need wont work with mod_perl 2.0. Ive been looking for what modules will and will not work with 2.0 (like Apache::DBI for pooling connections with MySQL). Would it be a better benefit to me to switch over to 2.0? Thanks, Jamie
Mod_rewrite
Can mod_rewrite be used to set PerlSetVar or PerlSetEnv variables? Jamie Krasnoo [EMAIL PROTECTED]
Best way to attach a module to /
What is the best way to attach a module to be run when a user first enters the site? use LocationMatch and set it to only match / as in ^/$ ? Thanks, Jamie Krasnoo [EMAIL PROTECTED]
Apache pnotes
The Eagle Books explanation of notes isn't very clear. Could someone point me to a page that explains it somewhat better? In what situation would it be beneficial to use them? Jamie Krasnoo [EMAIL PROTECTED]
Tracking down taint problems
I recently got this error: Insecure dependency in eval while running with -T switch. Callback called exit. Now, yes that tells me that something is wrong. What it doesn't tell me is where the problem is except for the fact that its somewhere in the current module that's being run. Is there a way that I could get mod_perl to fess up where the problem is? Jamie Krasnoo [EMAIL PROTECTED]
Search Engine Theory
Can anyone point me to any documents on search engine theory and programming search engines with perl? Jamie Krasnoo www.MyEBoard.com [EMAIL PROTECTED]
RE: possible solution for exec cgi SSI in mod_perl
Here's another way around it. You could use HTML::Template in place of SSI. Jamie -Original Message- From: Surat Singh Bhati [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 25, 2001 7:28 AM To: [EMAIL PROTECTED] Subject: possible solution for "exec cgi SSI" in mod_perl Hi, I am using lots of exec cgi SSI in my site, all the CGI called using exec are written in perl. !--#exec cgi="standardcgi.cgi"-- I want to take advantage of mod_perl for performance, but as I know "exec" will run as mod_cgi , not as mod_perl. Can I use !--#include virtual="modperlscript.pl"-- ? If above will run, will be run as a sub request.. ? Any other better solution to server the page included mod_perl scripts SSI in it, without running the subrequest/new process? Regards, -Surat Singh Bhati
Is it Apache or me?
I'm not quite sure how this works, and maybe I missed it in the Eagle book. I have a handler set in httpd.conf like this: Location / Set-Handler perl-script PerlHandler app::main /Location Now this works great when I want to go to the first page of the server. However if I try to go to a static page, that page gets intercepted and the app::main goes in to action. The handler doesn't intercept any of the other set locations. Why is it intercepting static pages? Is it a standard rule that a handler for Location / is never set? Thanks, Jamie Krasnoo www.MyEBoard.com [EMAIL PROTECTED] public key: http://www.planetphat.com/jkrasnoo/pgp.html
RE: Is it Apache or me?
Found a way around it. I used LocationMatch "^/$". Now it does what I want it to do. Thanks for your help guys. Jamie -Original Message- From: sterling [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 25, 2001 9:26 PM To: Jamie Krasnoo Cc: Modperl Subject: Re: Is it Apache or me? if you set a handler for / it will handle every request that way. you can either have all pages that are generated be /foo/ and set that as the location, or you can force all files with a certain suffix to be handled by mod_perl: Files ~ "*\.pl". sterling On Sun, 25 Feb 2001, Jamie Krasnoo wrote: I'm not quite sure how this works, and maybe I missed it in the Eagle book. I have a handler set in httpd.conf like this: Location / Set-Handler perl-script PerlHandler app::main /Location Now this works great when I want to go to the first page of the server. However if I try to go to a static page, that page gets intercepted and the app::main goes in to action. The handler doesn't intercept any of the other set locations. Why is it intercepting static pages? Is it a standard rule that a handler for Location / is never set? Thanks, Jamie Krasnoo www.MyEBoard.com [EMAIL PROTECTED] public key: http://www.planetphat.com/jkrasnoo/pgp.html
RE: Looking for a new distro
I found what the problem was, thanks to Michael Weiner (Hunter). For some reason, when mod_perl is compiled in to Apache as a static, it loads the file stated in PerlRequire twice. When I recompiled mod_perl as a DSO it stopped doing that. This bug seems like its a problem with the RedHat distro. I should have seen it. There may be a reason that RH 7.0 comes with Apache compiled with all mods in DSO. This problem doesn't seem to crop up on other distributions. Anyways, I think we can put this thread to bed. Thanks to everyone for your comments. Jamie -Original Message- From: Jeffrey A. Stuart [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 14, 2001 3:48 PM To: Clayton Cottingham aka drfrog; dreamwvr; Jamie Krasnoo Cc: Modperl Subject: RE: Looking for a new distro Hey just as an FYI... I've got mod_perl and apache 1.3.14 and PHP 4.04 (I think or maybe 4.03pl1) installed with no problems on my redhat 7 box. Now, it's my devel box so I don't know if there are any "major" problems with it. :) It does double duty as my devel box and my personal router (got my cable modem hooked up on it and then route my internal boxes through it. :)). For Apache/mod_perl/PHP, I downloaded the source and installed those directly along with Mysql... -- Jeff (FurBall) WebOverdrive Newbie Tech Board http://www.topniche.com/tech/ [EMAIL PROTECTED] -Original Message- From: Clayton Cottingham aka drfrog [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 13, 2001 6:05 PM To: dreamwvr; Jamie Krasnoo Cc: Modperl Subject: Re: Looking for a new distro heya all: im really waiting for the next bunch of releases here, im hoping that they all start doing a lil more QA before release!! ive tried a lot of different dists and nothing has me going "oh yeah!!" mandrake 7.2 is my current "lesser of Nth evils" last summer i went to town downloading everything from debian to suse and back to slack and redhat at the time i started using mandrake its mod_perl was sett up nice its not bad on 7.2 but it splits up so there is an httpd and an httpd-perl i dont like having to configure both so i un-rpmd then and rolled my own, DSO style install in less than thirty mins drop my config in and zoom!! again some of this has to do with how a dist sets up apache i like it all in /home/ww but most put the conf 's under /etc etc etc. some of these compatiblility file management issues drive me nuts!! and i usually uninstall and recomp my own well that my take on it anyhow -- back in the day we didn't have no old school -dr. frog
Looking for a new distro
Ok, I've had it with RH 7.0. Too many problems. What Linux distro are some of you using with Apache 1.3.14 and mod perl 1.24_01? Jamie
RedHat 7.0 and mod-perl
Is anyone using mod-perl with apache-1.3.14 on RedHat 7.0? Any complaints? Jamie Krasnoo
RE: RedHat 7.0 and mod-perl
I have one problem that realy is more of an annoyance than a threat. I've mentioned it before and realy got no solutions as to why this happens. On RedHat 7.0 when I have mod_perl-1.24_01 compiled in to apache-1.3.14 and have a PerlRequire set to startup.pl. It (startup.pl) seems to get run twice. I have dynamic subroutines loading up on startup so the init gets run twice when it starts. It doesn't damage anything when it happens but this problem only seems to happen with RedHat 7.0 and its an updated version of it too. Could be that the glibc is still funky after putting in the new rpm but its realy weird. One other thing is that when a stale pid file is present it seems to only run the startup file once, super weird. Not sure why it does this since I don't get this with any of the other Linux distros or earlier RH distros (6.2 on down seems to behave just fine). Jamie -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 09, 2001 2:19 AM To: Jamie Krasnoo Cc: Modperl Subject: Re: RedHat 7.0 and mod-perl Jamie Krasnoo wrote: Is anyone using mod-perl with apache-1.3.14 on RedHat 7.0? Any complaints? Me, core dumps. I recompiled perl_5.005_03 ,apache_1.3.12, mod_perl-1.24 and now it works: $ perl -v This is perl, version 5.005_03 $ telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. HEAD / HTTP1/0 HTTP/1.1 200 OK Date: Tue, 09 Jan 2001 10:18:21 GMT Server: Apache/1.3.12 (Unix) mod_perl/1.24 -- - frankie -
slight mod_perl problem
Ok, it seems that my startup.pl is being run twice on server start. Startup init running startup.pl - loading templates into memory --- Loaded template file user_reg.tmpl Startup init running startup.pl - loading templates into memory --- Loaded template file user_reg.tmpl [Wed Dec 20 15:18:21 2000] [notice] Apache/1.3.14 (Unix) mod_perl/1.24_01\ configured -- resuming normal operations Anyone have an explanation as to why this is happening, I have no hair left due to trying to figure this one out. Thanks for your help, Jamie
Re: slight mod_perl problem
startup.pl does not get repeated on a restart. However it will when started with ./apachectl start. I have never encountered this with Apache 1.3.12 or 13. Jamie On Thu, 21 Dec 2000, Stas Bekman wrote: On Wed, 20 Dec 2000, Jamie Krasnoo wrote: Ok, it seems that my startup.pl is being run twice on server start. Startup init running startup.pl - loading templates into memory --- Loaded template file user_reg.tmpl Startup init running startup.pl - loading templates into memory --- Loaded template file user_reg.tmpl [Wed Dec 20 15:18:21 2000] [notice] Apache/1.3.14 (Unix) mod_perl/1.24_01\ configured -- resuming normal operations Anyone have an explanation as to why this is happening, I have no hair left due to trying to figure this one out. See http://perl.apache.org/guide/config.html#Apache_Restarts_Twice_On_Start Apache restarts twice indeed, but it shouldn't rerun the startup.pl since it's already require()d and in %INC. Thanks for your help, Jamie _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://logilune.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Multiple Connections on Apache::DBI?
Apache::DBI overrides DBI in the creation of a connection to the database in order to cache the connection. So the connections you created below are seen as the same by Apache::DBI and when you change one you change the other since the connection is comming from the same persistent pool. Try specifying the database in the connection to make different rather than switching to it after connecting. ie: $DBI{db2} = join (":", $DBI{forum_db},$DBI{hostname}); That should create a difference between the two so Apache::DBI will keep them separate. And it also gets rid off an un-needed do() :) Good luck, Jamie On Wed, 13 Sep 2000, Mark D Wolinski wrote: Hi all, I'm using DBI to connect to a mySQL DB. I want to make two connections at the same time, as seen here: $DBI{database} = "DBI:mysql:db_a"; $DBI{hostname} = A hostname; $DBI{username} = A Username; $DBI{password} = A Password; $DBI{db} = join (":",$DBI{database},$DBI{hostname}); $db_driver = DBI-install_driver("mysql",$DBI{'username'},$DBI{'password'}); $db_master = DBI-connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, { RaiseError = 1}) || die $DBI::errstr; $DBI{forum_db} = "db_b"; $db_forums = DBI-connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, { RaiseError = 1}) || die $DBI::errstr; $db_forums-do( "use $DBI{forum_db}" ); Basically, $db_forums can be any number of different db's depending upon certain veriables, but to get a persistant connection, I'm connecting to the server and then "use"ing the correct DB. The problem that I have is that the system works fine under normal uses. However, when I run it under mod_perl and Apache_DBI, the $db_forums-do{"use $DBI{forum_db}" ); also changes the $db_master reference as well. So my question is, am I doing something wrong here? $db_master will always point to one database, but $db_forums will point to different ones. I can "use" a the correct db before each reference to it, but that seems like an awful lot of useless calls. I can't figure out why changing $db_forums would affect $db_master. Any clues are much appreciated. Mark W
Insecure $ENV{PATH} error
Could anyone tell me how to fix this error? [Thu Aug 24 11:29:14 2000] [error] Insecure $ENV{PATH} while running setgid at /usr/lib/perl5/5.6.0/Cwd.pm line 85. Its comming from the PerlRequire in my httpd.conf. I recently recompiled the kernel, could that be the problem? Thanks, Jamie
expiring pages with mod_perl
Sorry for the newbie question but could anyone tell me how to expire pages so a user can't use the back button to get back to that page? Thanks, Jamie
does anyone have a fix for this?
Hello all, I'm new to the list and I'm hoping that someone could help me and explain what I'm doing wrong or how to fix this I recently compiled mod_perl-1.24 and it can run modules that I program. However I get a segmentation fault (11) when I use a :: to describe where the module is. Example This works fine - Location /hello SetHandler perl-script PerlHandler hello /Location This causes the horrible [Wed Aug 2 22:34:30 2000] [notice] child pid 4433 exit signal Segmentation fault (11) to rear its ugly head even though the module was moved to /home/httpd/perl/app. Location /hello SetHandler perl-script PerlHandler app::hello /Location to help here's a copy of my startup.pl - basic nothing special #!/usr/bin/perl BEGIN { use Apache; use lib '/home/httpd/perl'; } 1; The help is much appreciated, I've lost half my hair tearing it out trying to find the cause of this problem. Thanks, Jamie Krasnoo
Seg fault (11) backtrace (long email) - was RE: does anyone have a fix for this?
Perl -V output: Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux, osvers=2.2.5-22smp, archname=i386-linux uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 09:11:51 edt 1999 i686 unknown ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='-O2 -m486 -fno-strength-reduce', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include' ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lposix -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Built under linux Compiled at Feb 2 2000 15:35:58 @INC: /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 Apache version 1.3.12. mod_perl version 1.24 Options: EVERYTHING=1 APACHE_SRC=../apache-1.3.12/src USE_APACI=1 DO_HTTPD=1 PERL_DEBUG=1 \ APACI_ARGS='--with-layout=RedHat --enable-module=rewrite --enable-module=inf o --enable-module=usertrack --enable-module=unique_id' test results: All tests successful, 4 tests skipped. Files=34, Tests=418, 27 wallclock secs (21.67 cusr + 2.58 csys = 24.25 CPU) kill `cat t/logs/httpd.pid` rm -f t/logs/httpd.pid rm -f t/logs/error_log Ok, Heres the backtrace I did. Program received signal SIGSEGV, Segmentation fault. 0x8086ef0 in perl_handler_ismethod () (gdb) bt #0 0x8086ef0 in perl_handler_ismethod () #1 0x8087bc3 in perl_call_handler () #2 0x80875cb in perl_run_stacked_handlers () #3 0x80859bd in perl_handler () #4 0x80a1db3 in ap_invoke_handler () #5 0x80b5289 in ap_some_auth_required () #6 0x80b52ec in ap_process_request () #7 0x80acbde in ap_child_terminate () #8 0x80acd6c in ap_child_terminate () #9 0x80acec9 in ap_child_terminate () #10 0x80ad4f6 in ap_child_terminate () #11 0x80adc83 in main () #12 0x400d09cb in __libc_start_main (main=0x80ad93c main, argc=4, argv=0xbb74, init=0x8060180 _init, fini=0x81271fc _fini, rtld_fini=0x4000ae60 _dl_fini, stack_end=0xbb6c) at ../sysdeps/generic/libc-start.c:92 I also did an strace I hope its of some help - gettimeofday({965330042, 362731}, NULL) = 0 stat("/web/myeboard/markup/html/hello", 0xb93c) = -1 ENOENT (No such file or directory) stat("/web/myeboard/markup/html", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0 open("/web/myeboard/markup/html/", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 5 fstat(5, {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0 fcntl(5, F_SETFD, FD_CLOEXEC) = 0 getdents(5, /* 5 entries */, 3933) = 96 getdents(5, /* 0 entries */, 3933) = 0 close(5)= 0 rt_sigaction(SIGALRM, NULL, {0x80aa050, [], SA_INTERRUPT|0x400}, 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 open("/web/myeboard/perl/app/hello.pm", O_RDONLY) = 5 fstat64(0x5, 0xbfffd0e8)= 0 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x401b read(5, "package hello;\n\nuse strict;\nuse "..., 4096) = 364 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 read(5, "", 4096) = 0 close(5)= 0 munmap(0x401b, 4096)= 0 --- SIGSEGV (Segmentation fault) --- I think I know what the problem is. If the module doesn't have its directory in the package declaration, it will seg fault. If its there, it runs fine. But even so, the server should give an error and complain that it can't find app::hello::handler instead of segmenting. The problem can be replicated with a simple hello world module. in the conf file is this Location /hello SetHandler perl-script PerlHandler app::hello /Location with the directory structure as /home/httpd/perl/app and the hello.pm residing in app. Run with the package declaration as "package app::hello;" then as "package hello;" -- should seg fault on this one and single server should die. I tried this with both stock RedHat kernel and 2.4.0-test5 kernel, same results both seg fault and