Gossamer Forum
Home : Products : Gossamer Links : Discussions :

mod_perl setup in FreeBSD/Apache

Quote Reply
mod_perl setup in FreeBSD/Apache
Having trouble getting mod_rewrite to work. We have .htaccess in the root directory set up with:
RewriteEngine On
RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^AddImages/(.*) AddImages/$1 [L]
RewriteRule ^Images/(.*) Images/$1 [L]
RewriteRule ^p/(.*) /cgi-bin/page.cgi?g=$1 [L]
RewriteRule ^info/(.*) /cgi-bin/page.cgi?p=$1 [L]
RewriteRule ^(.*).html /cgi-bin/page.cgi?g=$1.html [L]
RewriteRule ^$ /cgi-bin/page.cgi [L]

In httpd.conf, the virtual directory is configured thus:
<VirtualHost newsite.localareaguide.com>
DocumentRoot /home/localareaguide/www
ServerName newsite.localareaguide.com
ScriptAlias /cgi-bin/ "/home/localareaguide/www/cgi-bin/"
<Directory />
AllowOverride All
</Directory>
ErrorLog "|/usr/local/sbin/httplog -u log -g webclient /var/errorlogs/newsite/er%Y%m%d.err"
CustomLog "|/usr/local/sbin/httplog -u log -g webclient /var/accesslogs/newsite/ex%Y%m%d.log" combined
AccessFileName .htaccess
<Location /cgi-bin>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
</VirtualHost>

From my admin page when I click "Dynamic" the url looks like this:

http://newsite.localareaguide.com/cgi-bin/page.cgi?d=1

and links look like this:

http://newsite.localareaguide.com/...2Findex.html&d=1

The LinksSQL Help file says:
And to your perl startup file you need to add:
use lib '/full/path/to/admin';
use Links::mod_perl;

We don't know where to do this on our system.

Also, do we need somewhere in our httpd.conf file a PerlModule Apache::DBI or PerlRequire directive?

Thanks!
Quote Reply
Re: [mstackhouse] mod_perl setup in FreeBSD/Apache In reply to
OK - I've made it a lot further. I believe I have mod_perl running correctly, because when I run apachectl configtest I get these results:

Preloading Links SQL modules into mod_perl:
. . . . . . . .
All modules loaded ok!
Compiling all functions ... All modules compiled and loaded okay!

However, when I look at Environment on the Admin Panel, I see this:
System Information
======================================
Perl Version: 5.008005
Links SQL Version: 2.2.0
Running under mod_perl: No
Running under SpeedyCGI: No

And my URL's don't seem to be rewritten (although I'm not exactly sure how I can test).

Anyone want to take a stab?

Thanks!
Quote Reply
Re: [mstackhouse] mod_perl setup in FreeBSD/Apache In reply to
If you have shell with root access (which i presume you have), try rewrite stuff by utting in httpd.conf file not working from htaccess could have something to do with AllowOveride settings for the directory/host etc

HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================

Last edited by:

HyperTherm: Oct 21, 2004, 2:31 AM
Quote Reply
Re: [HyperTherm] mod_perl setup in FreeBSD/Apache In reply to
Thanks - that didn't seem to have an affect. When I go to http://www.wholesaleroom.com/cgi-bin/page.cgi?g=Mike I get my page fine, but when I go to http://www.wholesaleroom.com/Mike I get 404 Page not found.

Here's how my virtual host wound up:

<VirtualHost www.wholesaleroom.com>
DocumentRoot /home/wholesaleroom/www
ServerName www.wholesaleroom.com
ScriptAlias /cgi-bin/ "/home/wholesaleroom/www/cgi-bin/"
ErrorLog "|/usr/local/sbin/httplog -u log -g webclient /var/errorlogs/wholesaleroom/er%Y%m%d.err"
CustomLog "|/usr/local/sbin/httplog -u log -g webclient /var/accesslogs/wholesaleroom/ex%Y%m%d.log" combined
<Directory />
AllowOverride All
</Directory>
<Location /cgi>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
AccessFileName .htaccess
RewriteEngine On
RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^AddImages/(.*) AddImages/$1 [L]
RewriteRule ^Images/(.*) Images/$1 [L]
RewriteRule ^p/(.*) /cgi-bin/page.cgi?g=$1 [L]
RewriteRule ^info/(.*) /cgi-bin/page.cgi?p=$1 [L]
RewriteRule ^(.*).html /cgi-bin/page.cgi?g=$1.html [L]
RewriteRule ^$ /cgi-bin/page.cgi [L]
</VirtualHost>

Any more ideas?

Thanks!
Quote Reply
Re: [mstackhouse] mod_perl setup in FreeBSD/Apache In reply to
http://gossamer-threads.com/perl/gforum/gforum.cgi?post=265866;search_string=rewrite%20rules;t=search_engine#265866

HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================
Quote Reply
Re: [mstackhouse] mod_perl setup in FreeBSD/Apache In reply to
I think that if your Rewrite rules are in httpd.conf then you need a leading / in each rule - e.g.
RewriteRule ^/p/(.*) /cgi-bin/page.cgi?g=$1 [L]

Edit: I'd also point out that as far as I am concerned these rules are not doing anything

RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^AddImages/(.*) AddImages/$1 [L]
RewriteRule ^Images/(.*) Images/$1 [L]

as they are just rewriting urls to the same place.

Last edited by:

afinlr: Oct 21, 2004, 11:58 AM