httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <>
Subject Re: mod vhost sql
Date Sat, 09 Jun 2007 07:47:19 GMT
On Sat, 09 Jun 2007 09:12:45 +0200
Maikel Punie <> wrote:

> hey,
> I'm trying to write a mod_vhost_mysql, but this time one that can get
> all the data from the mysql db, and not just the docroot.

All what data?  Do you mean every apache directive, including
those implemented by third-party modules, should work in SQL?
If so, take a look at mod_macro, which gives you the crux of
the matter: namely a module feeding configuration to other

Also, please get MySQL out of your mindset here.  You should
the Apache DBD framework, so your module supports other
database backends automatically.

> So basically for every request the ap_hook_translate_name() is called
> to handle the function inside my module.

Now I'm confused.  *what* is the scope of this module?

> at the moment for every request thats done the modules does the
> following: 1- create a db connection
> 2- do the sql query
> 3- parse results
> 4- close db
> 5- return OK
> basically this isn't really nice to handle, creating a db connection
> and closing it for every request will create an enormous pressure on
> the mysql db server.

That's another reason to use mod_dbd.

> So now the question, is there a hook (or hooks) that is defined so i
> can call it,
> 1- just before the server actually starts running (after config
> parsing i guess)


> 2- just before the server stops running

No.  Use a pool cleanup.

> this way i could open up the db connection with hook one, and close it
> with hook two, this will decrease the load on the db server.

That's been a solved problem since mod_perl gave us the architecture
now known as LAMP, back in '95 (or was it '96?).  In the intervening
years we've moved on, and DBD solves two major issues you'll still
have if you just make the changes you're asking about here.

Nick Kew

Application Development with Apache - the Apache Modules Book

View raw message