user1700262
user1700262

Reputation: 291

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

How can I find out the path of the httpd.conf file on apache (PHP)? I do not know whether my script will be runned in windows apache or linux, i need to know where i can find this file in order to find a parameter from there. thanks!

Upvotes: 27

Views: 107274

Answers (6)

Rajeshkumar
Rajeshkumar

Reputation: 895

httpd -V

It will shows all compile settings, in the middle of the results you will find:

  • The Apache root directory: /usr/local/apache
  • The Apache config file path from the root directory: conf/httpd.conf

Apache conf file: /usr/local/apache/conf/httpd.conf

root@host [~]# httpd -V Server version: Apache/2.4.16 (Unix) Server built: Dec 15 2015 10:01:02 Cpanel::Easy::Apache v3.32.6 rev9999 Server's Module Magic Number: ... Server loaded: APR 1.5.2, APR-UTIL 1.5.4 Compiled using: APR 1.5.2, APR-UTIL 1.5.4 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/usr/local/apache" -D __SUEXEC_BIN="/usr/local/apache/bin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"

Upvotes: 11

Ganatra
Ganatra

Reputation: 6908

This is a classic way to locate httpd.conf file:

# find / -name 'httpd.conf' -print

Also you can file locate the file using

locate httpd.conf

Upvotes: 17

lupatus
lupatus

Reputation: 4248

I think its not exposed to PHP. Run httpd -V in terminal and you will find it there (command name depends on your system/apache version, it can be also apache -V):

bash-3.2# httpd -V
Server version: Apache/2.2.22 (Unix)
Server built:   Aug 24 2012 17:16:58
Server's Module Magic Number: 20051115:30
Server loaded:  APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/private/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"     <-- HERE IT IS

but if you only want to know the value of some configuration variable then phpinfo(), getenv() or apache_getenv() should be enough

Upvotes: 34

Varon
Varon

Reputation: 3916

If it isn't listed in phpinfo(), perhaps use

apache_getenv(/* variable */)

http://www.php.net/manual/en/function.apache-getenv.php

Upvotes: 0

Dv_
Dv_

Reputation: 31

if you are using xampp the file would be in this dir xampp\apache\conf

Upvotes: 2

arkascha
arkascha

Reputation: 42915

Look at the start of the output you get from phpinfo(), the basic apache configuration fodlers are shown there. So easiest is to make a trivial php script and call it once:

<?php phpinfo(); ?>

Likewise you can also directly query these settings. Check the documentation!

Upvotes: 4

Related Questions