You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by John Clement <jo...@readingroom.com> on 2008/11/26 13:22:44 UTC

[users@httpd] recovering a .conf file

I accidentally removed a .conf file from the conf.d directory.

I had hopes that I could get the config back using httpd -S, but it
seemingly only shows sites defined in the files that are still there and
not a great deal of detail at that.

Apache is still running, is there any way of dumping out the config from
the running apache?

Thanks in advance,

jc


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] recovering a .conf file

Posted by Brian Munroe <br...@gmail.com>.
On Wed, Nov 26, 2008 at 12:50 PM, André Warnier <aw...@ice-sa.com> wrote:

> It prints absolutely the full configuration, even directives I did not even
> know I had (probably the defaults assumed by Apache for some things).
> Only works if you have mod_perl though.
> This being said, since I do have mod_perl configured, I will leave this
> script installed, just in case I ever encounter the same problem as the OP
> here.

Awesome good to know!

-- brian

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] recovering a .conf file

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
> Brian Munroe wrote:
>> On Wed, Nov 26, 2008 at 8:21 AM, André Warnier <aw...@ice-sa.com> wrote:
>>> John Clement wrote:
> I was serious when I asked about mod_perl.
> Have a look here :
> http://perl.apache.org/docs/2.0/api/Apache2/Directive.html
> and particularly at
>  use Data::Dumper;
>   print Dumper $tree->as_hash;
> 
> So, is mod_perl installed as part of your Apache, or not ?
> 
> If it is installed, then it might be as simple as creating a small perl 
> script, copying it into your cgi-bin directory, and run it.
> 
> Maybe. I haven't tested it. But it would be worth a try.
> 
Replying to myself now.
Here is the perl script, could not resist trying it out.

#!/usr/bin/perl -w
use strict;
use Apache2::Directive ();
use Data::Dumper;
$Data::Dumper::Indent = 1;
my $tree = Apache2::Directive::conftree();
     print "Content-type: text/plain\n\n";
     print Dumper $tree->as_hash;
     exit 0;

It prints absolutely the full configuration, even directives I did not 
even know I had (probably the defaults assumed by Apache for some things).
Only works if you have mod_perl though.
This being said, since I do have mod_perl configured, I will leave this 
script installed, just in case I ever encounter the same problem as the 
OP here.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] recovering a .conf file

Posted by André Warnier <aw...@ice-sa.com>.
Brian Munroe wrote:
> On Wed, Nov 26, 2008 at 8:21 AM, André Warnier <aw...@ice-sa.com> wrote:
>> John Clement wrote:
I was serious when I asked about mod_perl.
Have a look here :
http://perl.apache.org/docs/2.0/api/Apache2/Directive.html
and particularly at
  use Data::Dumper;
   print Dumper $tree->as_hash;

So, is mod_perl installed as part of your Apache, or not ?

If it is installed, then it might be as simple as creating a small perl 
script, copying it into your cgi-bin directory, and run it.

Maybe. I haven't tested it. But it would be worth a try.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] recovering a .conf file

Posted by Brian Munroe <br...@gmail.com>.
On Wed, Nov 26, 2008 at 8:21 AM, André Warnier <aw...@ice-sa.com> wrote:
> John Clement wrote:
>>
>> I accidentally removed a .conf file from the conf.d directory.
>>
>> I had hopes that I could get the config back using httpd -S, but it
>> seemingly only shows sites defined in the files that are still there and
>> not a great deal of detail at that.
>>
>> Apache is still running, is there any way of dumping out the config from
>> the running apache?
>>

I *thought* there was a trick of causing the httpd to dump core, then
run strings on the corefile to aid in reconstruction.

Hopefully, you are running on a UNIX type OS...

-- brian

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] recovering a .conf file

Posted by André Warnier <aw...@ice-sa.com>.
John Clement wrote:
> I accidentally removed a .conf file from the conf.d directory.
> 
> I had hopes that I could get the config back using httpd -S, but it
> seemingly only shows sites defined in the files that are still there and
> not a great deal of detail at that.
> 
> Apache is still running, is there any way of dumping out the config from
> the running apache?
> 
How much is it worth to you ?
;-)

Seriously, if you have mod_perl installed, then I can think of a way 
which might potentially work.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org