获得从PHP Apache的Linux用户 [英] Get apache linux user from php
问题描述
我是一个外国的Linux系统上,并需要确定的Apache运行(也是如此PHP)的用户。
I'm on a foreign linux system and need to determine the user that apache runs on (and so does php).
目标:
我需要的脚本的所有者(这是因为我可以用SplFileInfo没问题),并将其与apache进程的所有者。
The aim: I need to get the owner of the script (this is no problem as I can use SplFileInfo) and compare it to the owner of the apache process.
我接受任何其他建议。
问候,
马里奥
Regards, Mario
编辑:
附加信息:
Additional info:
的脚本是一个缩微图生成器,使用XML文件来生成较大的图像大拇指。该脚本需要创建文件夹和写入文件。正如我不能影响PHP配置,我没有任何的shell访问,这必须非常安静方式完成。
创建过程通过例外stopps并发送邮件的功能衰竭。由于大多数PHP的功能不能在功能衰竭抛出异常,我需要一些人工检查,以确定我的环境,所以我需要apache用户比较它的一些目录或fileowner。
The script is a thumbnail generator, that uses an XML file to generate thumbs from larger images. The script needs to create folders and write files. As I cannot influence the php configuration and I do not have any shell access, this has to be done very silently. The creation process stopps via exception and sends a mail on failue. As most of php's function cannot throw exceptions on failue, I need some manual checks to determine the environment I'm in. Therefore I need the apache user to compare it to some directory or fileowner.
推荐答案
您可以调用PHP Exec的函数来执行的 WHOAMI 的:
You can call the php exec function to execute whoami:
<?php echo exec('whoami'); ?>
这篇关于获得从PHP Apache的Linux用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!