How can I view the complete httpd configuration?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How can I view the complete httpd configuration?



I'm trying to figure out what is the full complete configuration of an httpd setup.



All the configurations files are scattered in different files (/etc/httpd/conf.d, httpd.conf, various mod configs)



Is there a way to list the final httpd configuration?
Like the whole running setup configuration in a single file?





apachectl -S for running config, apachectl -M to show loaded modules
– arco444
Nov 26 '14 at 15:54


apachectl -S


apachectl -M





Except that apachectl -S does give you neither "the full complete configuration" nor " the whole running setup configuration in a single file".
– Frederick Nord
Feb 2 '17 at 16:39


apachectl -S





related : stackoverflow.com/questions/27152943 superuser.com/questions/922869 unix.stackexchange.com/questions/129026 serverfault.com/questions/425894 serverfault.com/questions/696164 serverfault.com/questions/500329 serverfault.com/questions/489018 serverfault.com/questions/42539 httpd.apache.org/docs/current/mod/mod_info.html httpd.apache.org/docs/current/invoking.html
– imme
Jul 19 '17 at 9:10





Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Web Applications Stack Exchange, Webmaster Stack Exchange or Unix & Linux Stack Exchange would be a better place to ask.
– jww
Dec 21 '17 at 2:08




3 Answers
3



As noted by arco444, you can use apachectl -S to display an overview of the VirtualHosts currently running from the configs, and apachectl -M to display all currently loaded modules - I'm not aware of a tool to display the verbose output of all configs parsed (and which order they were parsed in) at launch of httpd, but I would recommend that you familiarise yourself with the general structure of the httpd config files:


apachectl -S


apachectl -M



Of particular note to your question: the 'main' apache config file is located in /etc/httpd/conf/httpd.conf (in the region of line 221 on a default httpd installation from the repos included in CentOS 6, which I assume you are using based on your post tags), and the 'supplementary' config files are located in /etc/httpd/conf.d and require to be included explicitly in the main config file. For example, if you search the httpd.conf file for the term 'Include', you will find the line Include conf.d/*.conf which is what includes all files of extension .conf in the subdirectory conf.d - in alphabetical order, so you will want to familiarise yourself with the importance of config file parsing at some point if possible.


/etc/httpd/conf/httpd.conf


/etc/httpd/conf.d


httpd.conf


Include


Include conf.d/*.conf


.conf


conf.d



As an aside, if you are using a shell based text editor such as vim, I suggest that you enable line numbering and syntax highlighting by default so that such lengthy config files are a bit easier to parse yourself and navigate - in the case of vim, you'd do so by creating a file in your home directory called .vimrc (or append to an existing one) and add the following lines:


.vimrc


set nu
syntax on



Please use mod_info for that purpose:
http://httpd.apache.org/docs/2.2/mod/mod_info.html



only down side is that if you need it to recover a deleted config and haven't already loaded the module it won't help you much



As described in the Apache HTTP Server Documentation



If the config define -DDUMP_CONFIG is set, mod_info will dump the
pre-parsed configuration to stdout during server startup.


httpd -DDUMP_CONFIG -k start



or in Ubuntu do the following


sudo apache2ctl -DDUMP_CONFIG



If you want to strip the line numbers do


sudo apache2ctl -DDUMP_CONFIG | grep -vE "^[ ]*#[ ]*[0-9]+:$"



or redirect to a file


sudo apache2ctl -DDUMP_CONFIG | grep -vE "^[ ]*#[ ]*[0-9]+:$" > /path/to/dump.conf



Known Limitations



mod_info provides its information by reading the parsed configuration,
rather than reading the original configuration file. There are a few
limitations as a result of the way the parsed configuration tree is
created:






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results