首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >php引擎的实时日志

php引擎的实时日志
EN

Stack Overflow用户
提问于 2018-09-02 18:06:01
回答 2查看 93关注 0票数 0

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

因此,我正在为php网页寻找类似的东西。php为7.2

UPDATE1:

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

代码语言:javascript
复制
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

这是个丑陋的信息!我想我必须用一些路径运行semanage fcontext -a -t。不知道到底是哪条路!

UPDATE2:

下面的命令提供了一个更清晰的日志

代码语言:javascript
复制
[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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-09-02 18:48:24

这是一个SELinux问题,从日志消息中可以看出.

代码语言:javascript
复制
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'

从第一个错误开始,按照它的说法做。看看这能不能解决其他人。

如果在运行这些命令后仍然存在其他错误,请按照您收到的非常清楚的错误消息中的指示执行。

票数 1
EN

Stack Overflow用户

发布于 2018-09-02 18:52:47

这里是一个php的尾巴,从我的笔记周围玩。

它类似于 -n 5 access.log

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

要使它像-f一样运行,只需使用一个循环。

代码语言:javascript
复制
$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();
}

它也非常快,整个文件没有在内存中,就像尾巴。

SplFileObject

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52139759

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档