You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jérôme Renard <jr...@ez.no> on 2009/05/17 17:20:02 UTC
mod_dbd : connection aquisition issue
Good afternoon,
I have been developping an Apache module which uses the DBD framework.
I get the following issue :
If I call a URL which "belongs" to my test virtual host, like http://myvhost.lo/test/foo-bar
everything works fine.
However if I try a completely different URL which points to location externel to the
vhost, say http://localhost/path/to/a/folder/not/in/a/vhost I get the following message in the
error_log :
[Sun May 17 16:55:46 2009] [error] DBD: not configured
[Sun May 17 16:55:46 2009] [error] [client ::1] Unable to acquire a database connection
- mod_dbd and my module are loaded in httpd.conf
- the configuration for my VirtualHost is the following :
<VirtualHost *:81>
ServerName modurlalias.loc
DocumentRoot /path/to/my/virtualhost/
<IfModule mod_url_alias.c>
URLAliasEngine On
DBDriver mysql
DBDParams "host=myhost port=3306 user=foo pass=bar dbname=modurlalias"
</IfModule>
</VirtualHost>
- there is not other DBD* calls in httpd.conf or in any other configuration file.
What can be the source of such log messages ?
Maybe I did something wrong in the module's code but I did not find where yet.
The code is accessibile here :
- http://code.google.com/p/modurlalias/source/browse/trunk/src/mod_url_alias.c
Thanks in advance for any help.
Best Regards.
:)
Re: mod_dbd : connection aquisition issue
Posted by Jérôme Renard <jr...@ez.no>.
Hi Tom,
Tom Donovan a écrit :
> Jérôme Renard wrote:
>> Hi Tom,
>>
>> Tom Donovan a écrit :
>> [...]
>>> When your DBDriver and DBDParams directives are inside a
>>> <VirtualHost> block, they apply only to that virtual host. You
>>> might try moving these directives to be outside all your
>>> <VirtualHost> blocks. The database should then be available to all
>>> your virtual hosts.
>>
>> Thanks for the tip :)
>>
>> I see an issue with this though, here is a simple use case :
>>
>> - I want to use both "VirtualHosted" and non "VirtualHosted" sites on
>> my server.
>> For example I want to run :
>>
>> - http://site1.com -+
>> |----> points to 1.2.3.4
>> - http://site2.com -+
>>
>> - http://1.2.3.4/path/to/directory
>>
>> I could get two different DBD configurations for site1.com and
>> site2.com and
>> everything should work fine. But whenever when I hit
>> http://1.2.3.4/... I will
>> get a DBD error like shown in my original email in the error_log.
>>
>> Do you think that applying DBD* directives in a <Directory> context
>> would fix the problem ?
>>
>>>
>>> -tom-
>>>
>>> p.s. You might want to take a look at mod_vhost_dbd at
>>> http://dbd-modules.googlecode.com which is a similar module to yours.
>>
>> Thanks for the info I will have a look at it.
>>
>> Best Regards.
>>
> Hi Jerome,
>
> I don't think you can put mod_dbd directives (DBDriver, DBDParams, etc.)
> inside a <Directory> context. The docs for these directives say
> "Context: server config, virtual host" - so you can only use them at the
> top level, or inside a <VirtualHost> block. See
> http://httpd.apache.org/docs/2.2/mod/mod_dbd.html#dbdriver
Ok, RTFM was deserved here ;)
> The database that is configured for mod_dbd at the top level, outside
> any <VirtualHost> block, will be used for all non-virtual-host requests.
> It will also be used for any virtual hosts which do not have their own
> mod_dbd directives to override the default configuration.
Thanks !
--
Jérôme :)
Re: mod_dbd : connection aquisition issue
Posted by Tom Donovan <do...@bellatlantic.net>.
Jérôme Renard wrote:
> Hi Tom,
>
> Tom Donovan a écrit :
> [...]
>> When your DBDriver and DBDParams directives are inside a <VirtualHost>
>> block, they apply only to that virtual host. You might try moving
>> these directives to be outside all your <VirtualHost> blocks. The
>> database should then be available to all your virtual hosts.
>
> Thanks for the tip :)
>
> I see an issue with this though, here is a simple use case :
>
> - I want to use both "VirtualHosted" and non "VirtualHosted" sites on my
> server.
> For example I want to run :
>
> - http://site1.com -+
> |----> points to 1.2.3.4
> - http://site2.com -+
>
> - http://1.2.3.4/path/to/directory
>
> I could get two different DBD configurations for site1.com and site2.com
> and
> everything should work fine. But whenever when I hit http://1.2.3.4/...
> I will
> get a DBD error like shown in my original email in the error_log.
>
> Do you think that applying DBD* directives in a <Directory> context
> would fix the problem ?
>
>>
>> -tom-
>>
>> p.s. You might want to take a look at mod_vhost_dbd at
>> http://dbd-modules.googlecode.com which is a similar module to yours.
>
> Thanks for the info I will have a look at it.
>
> Best Regards.
>
Hi Jerome,
I don't think you can put mod_dbd directives (DBDriver, DBDParams, etc.) inside a <Directory>
context. The docs for these directives say "Context: server config, virtual host" - so you can only
use them at the top level, or inside a <VirtualHost> block. See
http://httpd.apache.org/docs/2.2/mod/mod_dbd.html#dbdriver
The database that is configured for mod_dbd at the top level, outside any <VirtualHost> block, will
be used for all non-virtual-host requests. It will also be used for any virtual hosts which do not
have their own mod_dbd directives to override the default configuration.
-tom-
Re: mod_dbd : connection aquisition issue
Posted by Jérôme Renard <jr...@ez.no>.
Hi Tom,
Tom Donovan a écrit :
[...]
> When your DBDriver and DBDParams directives are inside a <VirtualHost>
> block, they apply only to that virtual host. You might try moving
> these directives to be outside all your <VirtualHost> blocks. The
> database should then be available to all your virtual hosts.
Thanks for the tip :)
I see an issue with this though, here is a simple use case :
- I want to use both "VirtualHosted" and non "VirtualHosted" sites on my server.
For example I want to run :
- http://site1.com -+
|----> points to 1.2.3.4
- http://site2.com -+
- http://1.2.3.4/path/to/directory
I could get two different DBD configurations for site1.com and site2.com and
everything should work fine. But whenever when I hit http://1.2.3.4/... I will
get a DBD error like shown in my original email in the error_log.
Do you think that applying DBD* directives in a <Directory> context would fix the problem ?
>
> -tom-
>
> p.s. You might want to take a look at mod_vhost_dbd at
> http://dbd-modules.googlecode.com which is a similar module to yours.
Thanks for the info I will have a look at it.
Best Regards.
--
Jérôme :)
Re: mod_dbd : connection aquisition issue
Posted by Tom Donovan <do...@bellatlantic.net>.
Jérôme Renard wrote:
> Good afternoon,
>
> I have been developping an Apache module which uses the DBD framework.
>
> I get the following issue :
>
> If I call a URL which "belongs" to my test virtual host, like
> http://myvhost.lo/test/foo-bar
> everything works fine.
>
> However if I try a completely different URL which points to location
> externel to the
> vhost, say http://localhost/path/to/a/folder/not/in/a/vhost I get the
> following message in the
> error_log :
>
> [Sun May 17 16:55:46 2009] [error] DBD: not configured
> [Sun May 17 16:55:46 2009] [error] [client ::1] Unable to acquire a
> database connection
>
> - mod_dbd and my module are loaded in httpd.conf
> - the configuration for my VirtualHost is the following :
>
> <VirtualHost *:81>
> ServerName modurlalias.loc
> DocumentRoot /path/to/my/virtualhost/
>
> <IfModule mod_url_alias.c>
> URLAliasEngine On
> DBDriver mysql
> DBDParams "host=myhost port=3306 user=foo pass=bar
> dbname=modurlalias"
> </IfModule>
> </VirtualHost>
>
> - there is not other DBD* calls in httpd.conf or in any other
> configuration file.
>
> What can be the source of such log messages ?
>
> Maybe I did something wrong in the module's code but I did not find
> where yet.
>
> The code is accessibile here :
> -
> http://code.google.com/p/modurlalias/source/browse/trunk/src/mod_url_alias.c
>
>
> Thanks in advance for any help.
>
> Best Regards.
>
> :)
>
Hi Jerome,
When your DBDriver and DBDParams directives are inside a <VirtualHost> block, they apply only to
that virtual host. You might try moving these directives to be outside all your <VirtualHost>
blocks. The database should then be available to all your virtual hosts.
-tom-
p.s. You might want to take a look at mod_vhost_dbd at http://dbd-modules.googlecode.com which is a
similar module to yours.