Is there any way to get the Apache web server to display it's current running config, from memory, i.e. not by parsing the files in the config directories?

I've just managed to accidentally over-write the vhost config on a server (yes, I know, should have had a backup!), and while I can reconstruct it fairly easily (very new server, so simple config and hence no backup yet - that was tomorrow's task), was wondering if in general there was any way to get Apache to display its live running config, rather than just parsing the files (as httpd -S seems to do).

Have tried Googling and searching here on ServerFault, but not found anything. I can imagine this might save a few people's bacon over time. :)

1 Answer 1


This is how to recover Apache2 config from memory :

  1. grab the dump-all-memory-of-pid.sh script mentioned on this serverfault thread.

the Dump a linux process's memory to file

grep rw-p /proc/$1/maps | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' | while read start stop; do gdb --batch --pid $1 -ex "dump memory $1-$start-$stop.dump 0x$start 0x$stop"; done
  • put this in a file (eg. "dump-all-memory-of-pid.sh") and make it executable
  • usage: ./dump-all-memory-of-pid.sh [pid]
  • The output is printed to files with the names: pid-startaddress-stopaddress.dump
  • Dependencies: gdb

  1. get the pid of your apache process

    pgrep -uroot apache2

  1. dump the process's memory

    mkdir /tmp/apache_dump && cd /tmp/apache_dump
    sh /path/to/dump-all-memory-of-pid.sh <PID>

  1. grep all of the dump files for something that you expect to be in the apache config file.

    grep DocumentRoot *

  1. open the matched dump file(s) in vim and search for the string.

    vim 24374-7f159d56c000-7f159d72c000.dump

Search by typing "/", eg "/DocumentRoot", then simply copy out the text that you want.

source : http://forums.whirlpool.net.au/archive/2189742

  • Works great, thanks!... on CentOS I used pgrep -uroot apache2 Jun 28, 2017 at 1:22
  • I'm not sure what I was thinking in Jun 2017, but I just used pgrep -uroot httpd on CentOS... ignore previous me. Feb 23, 2018 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.