1

When I execute

s3cmd put --acl-public --guess-mime-type /html/file.png s3://bucket/files/file.png

via cmd in putty it works perfectly, however when I attempt to execute this via PHP :

system("s3cmd put --acl-public --guess-mime-type /html/file.png s3://bucket/files/file.png");

nothing happens. Does anyone have an idea of why it is not working? Do I have to modify a setting in php.ini or am I doing something wrong?

4
  • I tried exec as well and it does not work. Commented Jul 2, 2011 at 1:19
  • What type of server is it? (I believe on *nix commands are run as www-data and some commands are excluded) Commented Jul 2, 2011 at 1:21
  • You should also be able to use $response = exec('ls'); print_r($response); to see a response. Commented Jul 2, 2011 at 1:21
  • I tried outputting the response, but it is blank Commented Jul 2, 2011 at 1:28

4 Answers 4

1

I'll second the recommendation to look at the Apache log file, but I'll wager that this is a permissions issue (I've had that problem...). Does Apache (httpd?) have read/write access to /html/file.png and s3://bucket/files/file.png? Does s3cmd require special permissions? Do you need to use gksudo?

Sign up to request clarification or add additional context in comments.

2 Comments

I have checked Apache's error log file and it is reporting ERROR: Can't find a config file. Please use --config option. What is this for?
That sounds like an s3cmd command issue. My guess? It stores the config data in your home directory. You might be able to just copy it over from your home dir. Of course, you could also su into your Apache user and run s3cmd --configure
1

The s3cmd looks in a users home directory for the .s3cfg file. In your case, apache is probably the user running the program and apache doesn't have a .s3cfg file.

You need to run this again as the user that you intend to use s3cmd with.

/usr/bin/s3cmd --configure

Comments

0

There's maybe so restriction on the system command, you should try to look in the error_log, increase the error_reporting level or disable the safe_mode in php.ini

1 Comment

Safe_mode is off. For some reason PHP is not generating a error_log. The settings in php.ini look fine. If it is a permission problem what should I do to fix that? The owner of php files is set to root, in httpd.conf the owner is set to apache, could this be the problem?
0

there is some issue executing s3cmd from a php file (apache user) s3cmd can't find the s3cfg file, i put it in the command a it work:

s3cmd -c /var/www/.s3cfg put file...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.