Thursday, January 24, 2013

Finding Apache configuration file (httpd.conf) location and access log

Finding Apache configuration file (httpd.conf) location
Just a quick tip for programmers/administrator working with Apache or accessing a remote Linux server with putty.
Sometimes you need to backup or extract access_log or find the location of access_log so that you can generate HTML report using visitors http://shop.actimus.com/product_info.php?products_id=125
Since it's possible to configure apache from the source code there is no "default location" so I usually do:

$ ps -ef | grep apache

www 3085 12945 0 22:08 ? 00:00:00 /usr/local/apache2/bin/httpd
www 3323 12945 0 22:09 ? 00:00:00 /usr/local/apache2/bin/httpd
www 5253 12945 0 22:18 ? 00:00:00 /usr/local/apache2/bin/httpd
www 5256 12945 0 11:29 ? 00:00:02 /usr/local/apache2/bin/httpd
www 5270 12945 0 11:29 ? 00:00:02 /usr/local/apache2/bin/httpd
www 8062 12945 0 22:32 ? 00:00:00 /usr/local/apache2/bin/httpd
www 8685 12945 0 22:36 ? 00:00:00 /usr/local/apache2/bin/httpd
www 8820 12945 0 22:36 ? 00:00:00 /usr/local/apache2/bin/httpd
www 10294 12945 0 22:42 ? 00:00:00 /usr/local/apache2/bin/httpd
www 11097 12945 0 22:46 ? 00:00:00 /usr/local/apache2/bin/httpd
root 12498 9316 0 22:53 pts/0 00:00:00 grep --color=auto apache
root 12945 1 0 Jan13 ? 00:00:14 /usr/local/apache2/bin/httpd

Then simply run

$ /usr/local/apache2/bin/httpd -V

Server version: Apache/2.2.23 (Unix)
Server built: Jan 11 2013 16:12:42
....
Server compiled with....
-D SERVER_CONFIG_FILE="conf/httpd.conf"

conf folder is a sub folder of
/usr/local/apache2/

Then you can edit httpd.conf
and look for access log location
access_log
error_log
etc..

Some would say that you can use the following but it is not guarantee that this is
attached to the running instance
$ find / -name httpd.conf
Now you can generate a report

visitors /var/log/apache/access.log.*
or
zcat access.log.*.gz | visitors -

Enjoy!

No comments: