简体   繁体   English

fopen在弹性beantalk php上不起作用

[英]fopen is not working on elastic beanstalk php

I am using the following code in elastic beanstalk php to generate log file but I am getting this error.But the same code is working on another server. 我在弹性beantalk php中使用以下代码来生成日志文件,但出现此错误。但是相同的代码正在另一台服务器上工作。 How can I make it work ? 我该如何运作?

Error: 错误:

Error opening file in write mode!

Code : 代码:

$path="/var/www/html/aws";
$fileName =$path.'/logs/data'.date('Y-m-d_H-i-s'). '_' . uniqid() . '.txt';
$file = fopen($fileName,'w') or die('Could not create report file: ' . $fileName);
foreach($_POST as $key => $value) {
    $reportLine = $key." = ".$value."\n";
    fwrite($file, $reportLine) or die ('Could not write to report file ' . $reportLine);
}

fputs($file,"log aws");
fclose($file);

确保您的php用户www-data有权在$path.'/logs/文件夹中写入,或者只是logs文件夹logs0777 chmod

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

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