Last Updated on 1 month by Sachin G
Why do I need to find the httpd.conf on Linux?
One day, while debugging a misbehaving virtual host on an old CentOS server, I needed to check the Apache settings. Naturally, the first step was to edit the httpd.conf
file.
Simple, right? Not exactly.
Turns out, depending on the Linux distribution and the version of the Apache HTTP Server, the config file could be in several different places. That led me down the rabbit hole of figuring out how to reliably find httpd.conf on Linux—and here’s what I learned.
Most users do not know how to find or the path of the web server configuration file of Apache ( httpd ) in server.Apache having different configuration path on different OS , It depends on the installation of apache by which method is used.
How to Locate httpd.conf
in Linux
I was working across both Ubuntu and CentOS machines, and each had different paths. So, I began with the most basic method:
apachectl -V
OR
httpd -V | grep HTTPD_ROOT
Output :
-D SERVER_CONFIG_FILE="/etc/httpd/conf/httpd.conf"
and
httpd -V | grep SERVER_CONFIG_FILE
OUTPUT :
[Sun Apr 05 12:51:45.718351 2020] [so:warn] [pid 9654] AH01574: module ruid2_module is already loaded, skipping
-D SERVER_CONFIG_FILE="conf/httpd.conf"
This command is part of the apachectl command or httpd toolset, and the output includes a line like this: That line saved me. It confirmed exactly where the Apache configuration file lived on my OS box.
Another Extra Method
Get the Apache process through the ps command.
# ps -ef | grep apache
root 9317 9030 0 12:47 pts/0 00:00:00 grep –color=auto apache
apache 29870 942 0 09:12 ? 00:01:16 /usr/sbin/httpd -DFOREGROUND
apache 29911 942 0 09:12 ? 00:01:14 /usr/sbin/httpd -DFOREGROUND
apache 29920 942 0 09:12 ? 00:01:18 /usr/sbin/httpd -DFOREGROUND
apache 32156 942 0 01:25 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 32158 942 1 01:25 ? 00:08:43 /usr/sbin/httpd -DFOREGROUND
apache 32169 942 1 01:25 ? 00:08:44 /usr/sbin/httpd -DFOREGROUND
Get the path from process and run the below command.
[Sun Apr 05 12:49:36.333807 2020] [so:warn] [pid 9394] AH01574: module ruid2_module is already loaded, skipping
-D HTTPD_ROOT=”/etc/httpd”
Now from above two command output from HTTP_ROOT the main directory of apache is “/etc/httpd and configuration file is located under /etc/httpd , i.e “conf/httpd.conf” and full path will be “/etc/httpd/conf/httpd.conf“
For Ubuntu or Debian-based systems
# ps -ef | grep apache
# /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
Where is the Apache Config File in Linux? (By Distribution)
Through testing, I noted these default locations:
CentOS / RHEL:
- Path of httpd.conf: /etc/httpd/conf/httpd.conf
- Additional configs: /etc/httpd/conf.d/ (modular conf.d directory)
Ubuntu / Debian:
- Path of httpd.conf: Ubuntu often doesn’t use
httpd.conf
directly. Instead:- Main file:
/etc/apache2/apache2.conf
- Virtual hosts:
/etc/apache2/sites-available/
- Modules:
/etc/apache2/mods-enabled/
- Main file:
I was used to finding everything in httpd.conf
But Ubuntu’s Apache setup is more modular.
If you’re not sure where the default config path is or if Apache was compiled from source, this command helped me a lot:
find / -name httpd.conf 2>/dev/null
This finds any httpd.conf
on the system, though it might take a few seconds. Very useful on unfamiliar setups.
Points to Remember
- Apache config structures vary greatly by distro.
- The
apachectl -V
Command is your best friend.
- Always check the conf.d directory for modular configs.
- Even if there are no
httpd.conf
, other files likeapache2.conf
or.conf
files insites-available/
may be active.
Finding and understanding your Apache config file is essential for any web server setup. Whether you’re on Ubuntu, CentOS, or Red Hat Enterprise Linux (RHEL), you now have the tools and terminal knowledge to find and edit your Apache settings confidently.
If you want to learn about the find
command, you can follow this link.
I’m Sachin Gupta — a freelance IT support specialist and founder of techtransit.org. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!