使用PHP的Apache日志设置REMOTE_USER [英] Setting REMOTE_USER for apache logs using php

查看:202
本文介绍了使用PHP的Apache日志设置REMOTE_USER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mod_perl的,我可以这样做:

In mod_perl i can do something like:

$r->user("username");

和则用户名会在日志中的用户名部分显示出来。

And then the username will show up in the username section in the logs.

有没有办法在PHP做到这一点?而无需修改Apache的?

Is there a way to do this in php? without having to modify apache?

修改:到目前为止,我都试过:

Edit: So far i've tried both:

$_SERVER['REMOTE_USER'] = "username";
$_SERVER['PHP_AUTH_USER'] = "username";
apache_setenv('REMOTE_USER', "username")

没有运气

EDIT2:
Apache日志是的格式为:

Apache logs are in the format of:

ip地址 REMOTE_USER 识别日期时间...等

ipAddress REMOTE_USER IDENT datetime... etc

我试图设置REMOTE_USER不使用apache的的mod_auth,但是PHP code。

I'm trying to set REMOTE_USER without using apache's mod_auth, but php code.

推荐答案

这看起来像一个可能的选择: apache_setenv()

This looks like a likely option: apache_setenv()

这篇关于使用PHP的Apache日志设置REMOTE_USER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆