【问题标题】:How to access to apache log?如何访问apache日志?
【发布时间】:2018-01-14 07:34:55
【问题描述】:

我有一个centos7,我已经安装了httpd和mysqld。

我想通过以下方式访问 apache 登录 /var/httpd/log

echo file_get_contents("/var/log/httpd/domains/example.com.log");

但它不起作用。

【问题讨论】:

  • 如何运行这个脚本?使用网络浏览器?那么您将无法访问此文件。
  • 它作为 php 文件在网络服务器上运行。
  • 你不能直接这样做,网络服务器经常在www-data下运行,它没有这样做的权限,more about this
  • 在其他服务器上我有 centos 和 directadmin 并且在 directadmin 中,我可以访问日志。
  • 你拼错了“.log”。

标签: php apache centos


【解决方案1】:

您的代码似乎是 PHP 语法,对吗?

file_get_contents();只能通过相对链接或URI获取WEB ROOT下的文件。

【讨论】:

    猜你喜欢
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 2012-08-09
    • 2019-03-16
    相关资源
    最近更新 更多