ChatGPT解决这个技术问题 Extra ChatGPT

Lost httpd.conf file located apache [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 years ago. Improve this question

How can I find where my httpd.conf file is located?

I am running an Ubuntu Linux server from the Amazon Web Services EC2 (Elastic Compute Cloud) and I can't find my Apache config.

Which OS are you using? How did you install Apache? Which version of Apache are you running? These are all things that you should include when this gets moved the correct place (probably SeverFault).
Shouldn't this be migrated to superuser.com instead of closing?
Here's a quick way: find / -name httpd.conf
For red hat, usually: /etc/httpd/conf/httpd.conf access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…
Here's another quick way: locate httpd.conf

I
Ivan Chau

Get the path of running Apache

$ ps -ef | grep apache
apache   12846 14590  0 Oct20 ?        00:00:00 /usr/sbin/apache2

Append -V argument to the path

$ /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

Reference:
http://commanigy.com/blog/2011/6/8/finding-apache-configuration-file-httpd-conf-location


In some OS's you will get the relative path of conf file : -D SERVER_CONFIG_FILE="apache2.conf" You can run "/usr/sbin/apache2 -V | grep HTTPD_ROOT" to find the root. Output: "-D HTTPD_ROOT="/etc/apache2/apache2.conf" The absolute path will be then : "/etc/apache2/apache2.conf"
Doesn't work on my shared host since ps only shows tasks running as me. I had to just try running "httpd -V" and "apache2ctl -V" as Rich Bower suggests.
I'm on ubuntu 14.04 with Apache2 and sudo /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE gives me some warning errors Invalid Mutex directory so the right command I used is sudo apachectl -V | grep SERVER_CONFIG_FILE
Didn't work for me on Ubuntu 16.04. It just returns the PID of grep.
R
Rich Bowen

See http://wiki.apache.org/httpd/DistrosDefaultLayout for discussion of where you might find Apache httpd configuration files on various platforms, since this can vary from release to release and platform to platform. The most common answer, however, is either /etc/apache/conf or /etc/httpd/conf

Generically, you can determine the answer by running the command:

httpd -V

(That's a capital V). Or, on systems where httpd is renamed, perhaps apache2ctl -V

This will return various details about how httpd is built and configured, including the default location of the main configuration file.

One of the lines of output should look like:

-D SERVER_CONFIG_FILE="conf/httpd.conf"

which, combined with the line:

-D HTTPD_ROOT="/etc/httpd"

will give you a full path to the default location of the configuration file


For me, what worked is the apache2ctl -V command and looking for the path in what is listed after.
yep, apache2ctl is not renamed version of httpd, it's different names of same aplication on Debian- and RedHat-based OS respectively
I get the command httpd was not found.
Try "apachectl -V" if "httpd -V" don't work
On ubuntu you may have apache2.conf file and not an httpd.conf file. You can find the file listed under /etc/apache2 directory