Forum Moderators: phranque

Message Too Old, No Replies

RewriteMap (prg) and RewriteLock

Where to put files?

         

Peter

8:45 pm on Oct 4, 2007 (gmt 0)

10+ Year Member



Hello. I've two questions, if you please.

First, is there any convention on where in the filesystem one should put a RewriteMap perl script (with Apache 2 on Debian) and the RewriteLock file? And does the RewriteLock file have to exist already, or does Apache create it at the specified location?

Secondly, am I right in thinking that a RewriteMap perl script is started with Apache, and can create, change and keep arrays in memory until the next restart of Apache?

Thank you,
Peter.

jdMorgan

9:05 pm on Oct 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know of any convention for the lock file, but you'd probably want your RewriteMap located with other Web site admin scripts in non-HTTP-accessible filespace.

The lock file is dynamically-created, and you should not have to create it unless the server permissions are configured 'differently,' allowing mod_rewrite to write to, but not create the lock file. In that case, you'd want to create an empty writeable file for Apache to start with.

RewriteMap prg scripts are started with Apache, and 'listen' to STDIN, where the requests initiated by mod_rewrite referencing ${MapName:Key} appear. Output goes back to mod_rewrite on STDOUT.

Jim

Peter

3:01 am on Oct 5, 2007 (gmt 0)

10+ Year Member



Thanks, Jim.

There's a directory /var/lock/apache2/ which seems to be appropriate. Apache doesn't leave any trace of a lock file here, but doesn't complain, so I suppose it's working.

Two surpises (they shouldn't have been, but I mention them in case it's useful for anyone), Top shows the perl script running under root, and you must make sure that the output ends with a return: in other words, print "F\n" for instance rather than just print"F".

Regards,
Peter.

jdMorgan

3:26 am on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, newline is required, as documented:
It then has to give back the looked-up value as a newline-terminated string on stdout or the four-character string "NULL" if it fails

Jim