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 th
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!
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
httpd -V
It will shows all compile settings, in the middle of the results you will find:
/usr/local/apache
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"
if you are using xampp the file would be in this dir xampp\apache\conf
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
If it isn't listed in phpinfo(), perhaps use
apache_getenv(/* variable */)
http://www.php.net/manual/en/function.apache-getenv.php