AWS S3 PHP脚本在从SSH运行时有效,但在浏览器中无法运行

I have a script that links to my AWS S3 service. It's a test script that creates a random bucket and puts a text file in the bucket.

When executed via SSH [root@html] php ./sample.php

it executes without errors, the bucket is create and the file is created in the bucket.

However when I try to run via browser, it stops just before the command line to create the bucket and the script seems to end suddenly. The browser does not display any error message.

I'm not sure what it is that I'm missing out on. I've tried on Safari, IE 9, Chrome and Firefox. All gave a similar result.

Below is the script mentioned above,

<?php
// Include the SDK using the Composer autoloader
require 'vendor/autoload.php';

use Aws\S3\S3Client;
$client = S3Client::factory();

$bucket = uniqid("php-sdk-sample-", true);
echo "Creating bucket named {$bucket}
";     <--- This line displayed when run from browser 
$result = $client->createBucket(array('Bucket' => $bucket));

// Wait until the bucket is created
$client->waitUntilBucketExists(array('Bucket' => $bucket));


$key = 'hello_world.txt';
echo "Creating a new object with key {$key}
";
$result = $client->putObject(array(
    'Bucket' => $bucket,
    'Key'    => $key,
    'Body'   => "Hello World!"));


echo "Downloading that same object:
";
$result = $client->getObject(array(
    'Bucket' => $bucket,
    'Key'    => $key));

echo "
---BEGIN---
";
echo $result['Body'];
echo "
---END---

";

?>

Do you have any PHP CLI modules loaded which may make it work from command line but not from your webserver? OR could it be that you have set your AWS credentials which are for the S3Client in your command line environment variables so you must manually enter them when building your S3Client ?