php引擎的实时日志

php引擎的实时日志,php,centos7,Php,Centos7,有没有办法在线观看php活动?我正在寻找类似apache日志的东西,我可以在终端中运行tail-f/var/log/httpd/access.log,然后在浏览器中打开URL,查看apache打印的内容 所以,我正在为php网页寻找类似的东西。php是7.2 更新1: 尝试使用tail-f/var/log/messages查看系统日志,当从浏览器重新加载页面时,我在终端中收到许多类似的消息 python: SELinux is preventing /usr/sbin/httpd from wr

有没有办法在线观看php活动?我正在寻找类似apache日志的东西,我可以在终端中运行
tail-f/var/log/httpd/access.log
,然后在浏览器中打开URL,查看apache打印的内容

所以,我正在为php网页寻找类似的东西。php是7.2

更新1:

尝试使用
tail-f/var/log/messages
查看系统日志,当从浏览器重新加载页面时,我在终端中收到许多类似的消息

python: SELinux is preventing /usr/sbin/httpd from write access on the directory /var/www/html/ow_userfiles/plugins/admin.#012#012*****  Plugin httpd_write_content (92.2 confidence) suggests   ***************#012#012If you want to allow httpd to have write access on the admin directory#012Then you need to change the label on '/var/www/html/ow_userfiles/plugins/admin'#012Do#012# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/ow_userfiles/plugins/admin'#012# restorecon -v '/var/www/html/ow_userfiles/plugins/admin'#012#012*****  Plugin catchall_boolean (7.83 confidence) suggests   ******************#012#012If you want to allow httpd to unified#012Then you must tell SELinux about this by enabling the 'httpd_unified' boolean.#012#012Do#012setsebool -P httpd_unified 1#012#012*****  Plugin catchall (1.41 confidence) suggests   **************************#012#012If you believe that httpd should be allowed write access on the admin directory by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'httpd' --raw | audit2allow -M my-httpd#012# semodule -i my-httpd.pp#012
这是一个丑陋的信息!我想我必须用一些路径运行
semanagefcontext-a-t
。不知道到底是哪条路

更新2:

使用以下命令可以获得更清晰的日志

[root@localhost html]# sealert -l e254cabb-7005-4a3c-8f91-8620c924c5e0
SELinux is preventing /usr/sbin/httpd from write access on the file /var/www/html/ow_includes/config.php.

*****  Plugin httpd_write_content (92.2 confidence) suggests   ***************

If you want to allow httpd to have write access on the config.php file
Then you need to change the label on '/var/www/html/ow_includes/config.php'
Do
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/ow_includes/config.php'
# restorecon -v '/var/www/html/ow_includes/config.php'

*****  Plugin catchall_boolean (7.83 confidence) suggests   ******************

If you want to allow httpd to unified
Then you must tell SELinux about this by enabling the 'httpd_unified' boolean.

Do
setsebool -P httpd_unified 1

*****  Plugin catchall (1.41 confidence) suggests   **************************

If you believe that httpd should be allowed write access on the config.php file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
# semodule -i my-httpd.pp


Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                unconfined_u:object_r:httpd_sys_content_t:s0
Target Objects                /var/www/html/ow_includes/config.php [ file ]
Source                        httpd
Source Path                   /usr/sbin/httpd
Port                          <Unknown>
Host                          localhost.localdomain
Source RPM Packages
Target RPM Packages
Policy RPM                    selinux-policy-3.13.1-192.el7_5.6.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     localhost.localdomain
Platform                      Linux localhost.localdomain
                              3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14
                              21:49:04 UTC 2018 x86_64 x86_64
Alert Count                   108
First Seen                    2018-09-02 16:51:25 +0430
Last Seen                     2018-09-02 23:00:19 +0430
Local ID                      e254cabb-7005-4a3c-8f91-8620c924c5e0

Raw Audit Messages
type=AVC msg=audit(1535913019.143:9913): avc:  denied  { write } for  pid=5121 comm="httpd" name="config.php" dev="dm-0" ino=18219610 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_sys_content_t:s0 tclass=file


Hash: httpd,httpd_t,httpd_sys_content_t,file,write
[root@localhosthtml]#sealert-l e254cabb-7005-4a3c-8f91-8620c924c5e0
SELinux正在阻止/usr/sbin/httpd对文件/var/www/html/ow_includes/config.php进行写访问。
*****插件httpd_write_内容(92.2置信度)建议***************
如果希望允许httpd对config.php文件具有写访问权限
然后需要更改“/var/www/html/ow_includes/config.php”上的标签
做
#semanage fcontext-a-t httpd_sys_rw_content_t'/var/www/html/ow_includes/config.php'
#restorecon-v'/var/www/html/ow_includes/config.php'
*****插件catchall_boolean(7.83置信度)建议******************
如果您想允许httpd统一
然后,您必须通过启用“httpd_统一”布尔值来告诉SELinux这一点。
做
setsebool-P httpd_统一1
*****插件catchall(1.41置信度)表明**************************
如果您认为默认情况下应该允许httpd对config.php文件进行写访问。
然后,您应该将其报告为bug。
您可以生成本地策略模块以允许此访问。
做
通过执行以下操作暂时允许此访问:
#ausearch-c'httpd'-原始审核2允许-M我的httpd
#semodule-i my-httpd.pp
其他信息:
源上下文系统:系统:httpd\u t:s0
目标上下文未定义\u u u:object\r:httpd\u sys\u content\u t:s0
Target Objects/var/www/html/ow_includes/config.php[文件]
源httpd
源路径/usr/sbin/httpd
港口
主机localhost.localdomain
源RPM包
目标RPM包
政策RPM selinux-Policy-3.13.1-192.el7_5.6.noarch
Selinux已启用True
策略类型目标
强制执行模式强制执行
主机名localhost.localdomain
平台Linux localhost.localdomain
3.10.0-862.11.6.el7.x86_64#1 SMP周二8月14日
21:49:04 UTC 2018 x86_64 x86_64
警报计数108
第一次看到2018-09-02 16:51:25+0430
最后一次看到2018-09-02 23:00:19+0430
本地ID e254cabb-7005-4a3c-8f91-8620c924c5e0
原始审核消息
type=AVC msg=audit(1535913019.143:9913):AVC:denied{write}for pid=5121 comm=“httpd”name=“config.php”dev=“dm-0”ino=18219610 scontext=system\u:system\r:httpd\t:s0 tcontext=unconfined\u:object\r:httpd\u系统内容\u t:s0 tclass=file
散列:httpd,httpd,httpd系统内容,文件,写入
这是一个问题,从日志消息中可以明显看出

SELinux is preventing /usr/sbin/httpd from write access on the directory /var/www/html/ow_userfiles/plugins/admin.#012#012*****  
...
If you want to allow httpd to have write access on the admin directory
Then you need to change the label on '/var/www/html/ow_userfiles/plugins/admin'

 semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/ow_userfiles/plugins/admin'
 restorecon -v '/var/www/html/ow_userfiles/plugins/admin'
从第一个错误开始,完全按照它的说明进行操作。。看看这是否能解决其他问题


如果在运行这些命令后仍然存在其他错误,请按照您收到的非常清晰的错误消息中的说明进行操作。

这里是我的笔记中的php“tail”供您使用

它类似于tail-n5 access.log

这将回答access.log的最后5行

要使它像tail-f一样工作,只需使用一个循环

$check = "access.log";
$end = "5";

$fp= fopen($check, "r");
$count=0;
while($line = fgetss($fp))
$count++;
// echo "Total lines ".$count.PHP_EOL;
fclose($fp);

$start = $count - $end;

$file = new SplFileObject($check);
$file->seek($start);
for($i = 0; !$file->eof() && $i < $end; $i++) {
  echo $file->current(); 
  $file->next();
}
$check=“access.log”;
$end=“5”;
$fp=fopen($r)支票);
$count=0;
而($line=fgetss($fp))
$count++;
//echo“总行数”。$count.PHP\u EOL;
fclose($fp);
$start=$count-$end;
$file=新的SplFileObject($check);
$file->seek($start);
对于($i=0;!$file->eof()&&$i<$end;$i++){
echo$file->current();
$file->next();
}
它也是非常快的,整个文件没有被存储在内存中,就像tail一样


您希望在这些php日志中看到什么?如果apache是web服务器,为什么不使用apache的日志呢?我在递归写入权限方面遇到了一些错误。尽管我确实访问了apache:apache/var/www/html,但我不知道它实际上正在访问哪个文件或文件夹。我还没有写代码。这是一个网站安装的一部分。你现在把我弄丢了,我不知道看访问日志与你上次的评论有什么关系。我读到php可以通过内置服务器
-S
运行。当我运行
php72-S时http://w.x.y.z
,我得到了
无效地址
错误。似乎通过运行
-S
,我可以看到php正在做什么的实时日志。但是不确定…嗯
setsebool-P httpd_unified 1
这是第三个命令完成了任务。