繁体   English   中英

PHP脚本创建文件不是来自用户www数据

[英]Php-script create file not from user www-data

我的名字lebnik,以及关于我的信息:

# id lebnik
uid=1000(lebnik) gid=1000(lebnik) groups=1000(lebnik),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)

我的Apache从用户www-data运行php脚本,请检查以下内容:

root@debian /etc/apache2 # grep -R "APACHE_RUN_USER=" .
./envvars:export APACHE_RUN_USER=www-data

有关用户www-data的信息:

# id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)

我创建php-script file.php:

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);

echo `whoami`;

$file = __FILE__.'.tmp';

file_put_contents($file, 'Hi');

echo file_get_contents($file)."\n";

$dirname = dirname(__FILE__);

echo `ls -la $dirname`;
?>

接下来,我尝试使用Apache调用脚本:

# curl http://starsite.l/test/file.php
www-data
Hi
total 16
drwxrwxrwx 1 lebnik www-data 4096 Oct 18 00:49 .
drwxrwxr-x 1 lebnik www-data 4096 Oct 18 00:36 ..
-rw-rw-r-- 1 lebnik www-data  225 Oct 18 00:46 file.php
-rw-r--r-- 1 lebnik www-data    2 Oct 18 00:49 file.php.tmp

你看到这个了吗? PHP从用户lebnik创建文件file.php.tmp 我的配置有什么问题?

抱歉,我从错误的用户挂载了VirtualBox中的文件夹:

mount -t vboxsf -o uid=1000,gid=33 starsite.l /var/www/starsite.l

正确安装:

mount -t vboxsf -o uid=33,gid=33 starsite.l /var/www/starsite.l

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM