【发布时间】:2018-03-22 03:25:21
【问题描述】:
这是我在 AWS 服务器上在线使用的脚本:
<?php
require './awsPackage/aws-autoloader.php';
use \Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Exception\DynamoDbException;
$tableName = "table_name";
$ddb = DynamoDbClient::factory(array(
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => array('key' => '<my_key>',
'secret' => '<my_secret_key>'))); // EC2 role security
try {
$result = $ddb->describeTable(array(
"TableName" => $tableName
));
} catch (ResourceNotFoundException $e) {
// if this exception is thrown, the table doesn't exist
return false;
}
echo "<pre>";
print_r($result);
echo "</pre>";
if ($tableName == $result['Table']['TableName'])
{
echo $result['Table']['TableName'].": ".$result['Table']['TableStatus'];
}
else
{
echo $tableName." INACTIVE";
}
?>
我正在使用此代码检查在线 AWS 服务器上的 DynammoDB 中是否存在提供的表。
设置本地服务器后,此代码在 Windows 上运行良好。
但是当我在线制作这段代码时。它加载页面,然后给出 500 的错误。可能是什么原因?
这是错误日志:
[Wed Mar 21 18:54:19.043570 2018] [:error] [pid 2831] [client 49.35.89.185:1410] PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /var/www/html/test/awsPackage/Aws/Api/DateTimeResult.php:19\nStack trace:\n#0 /var/www/html/test/awsPackage/Aws/Api/DateTimeResult.php(19): DateTime->__construct('2018-03-21T12:4...')\n#1 /var/www/html/test/awsPackage/Aws/Api/Parser/JsonParser.php(49): Aws\\Api\\DateTimeResult::fromEpoch(1521636246.401)\n#2 /var/www/html/test/awsPackage/Aws/Api/Parser/JsonParser.php(24): Aws\\Api\\Parser\\JsonParser->parse(Object(Aws\\Api\\TimestampShape), 1521636246.401)\n#3 /var/www/html/test/awsPackage/Aws/Api/Parser/JsonParser.php(24): Aws\\Api\\Parser\\JsonParser->parse(Object(Aws\\Api\\Struct in /var/www/html/test/awsPackage/Aws/Api/DateTimeResult.php on line 19
【问题讨论】:
-
查看网络服务器错误日志 500 错误通常意味着灾难性的 PHP 错误
-
在哪里可以找到该日志?
-
我会查看 AWS 文档
-
好的。谢谢,我知道了,我在
var/log/httpd/ -
@RiggsFolly 我用错误日志更新了问题。请看一下。
标签: php amazon-web-services amazon-s3 amazon-ec2 amazon-dynamodb