Apache Redhat 列出 /foo/ 从命令行被命中的次数

Apache Redhat list how many times /foo/ was hit from command line

到目前为止,我无法在网上或任何书籍中找到答案。我想计算 /foo/ 在我的网站上被点击了多少次。如果有人能帮忙,谢谢!

在命令行中输入:

grep -c '/foo/' /var/log/httpd/access_log 

这将显示 apache 访问日志文件中“/foo/”的计数。

访问日志文件较多:

access_log.2 access_log.4
access_log.1 access_log.3 access_log.5

如果您想查看旧条目的结果,则可以使用

grep -c '/foo/' /var/log/httpd/access_log*

结果:

/var/log/httpd/access_log:46
/var/log/httpd/access_log.1:85
/var/log/httpd/access_log.2:46
/var/log/httpd/access_log.3:103
/var/log/httpd/access_log.4:70
/var/log/httpd/access_log.5:177

路径取决于您的 Redhat 版本。

http://www.itninja.com/blog/view/mysql-and-apache-profile-log-path-locations