Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and cURL in Amazon EC2 in www folder
    primarykey
    data
    text
    <p>PHP and cURL work fine in a non-webfacing directory in my amazon EC2 micro install, 12.04.2 LTS (GNU/Linux 3.2.0-40-virtual x86_64).</p> <p>I'm able to run some scripts on the command line using cURL:</p> <pre><code> #!/usr/bin/php $command = '/absolute/path/to/running/process'; $url = 'http://example.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 400); curl_setopt($ch, CURLOPT_TIMEOUT, 400); $resp = json_decode(curl_exec($ch), 1); $data1 = round($resp["data1"], 6); $data2 = round ($resp["data2"], 2); curl_close($ch); $c = array( 'var1' =&gt; trim(shell_exec($command)), 'var2' =&gt; trim(shell_exec($command)), 'var3' =&gt; trim(shell_exec($command)), 'var4' =&gt; number_format($data1, 6, '.', ''), 'var5' =&gt; number_format($data2, 0, '.', ',') ); var_dump($c); </code></pre> <p>This works fine.</p> <p>However, as soon as I put this same script in the web facing directory (I remove <code>#!/usr/bin/php</code> obviously), the page loads (I can type <code>echo 'Hello World!'</code> at the very top and see the text on a browser from a remote machine), but the page is entirely blank and adding <code>echo</code> statements after <code>curl</code> results in nothing. If I comment out the <code>curl</code> function calls and try to simply execute the command, it seems to not work (The entire array of values is populated with <code>NULL</code> or <code>0</code>.).</p> <ul> <li>What's going on with PHP? Why won't cURL run in the /var/www/ folder but runs fine everywhere else? I'm storing information to a database using cURL to get some JSON from public APIs.</li> <li>Why can't I use <code>shell_exec</code> to run a script as I normally could using PHP on the command line?</li> <li>Errors aren't showing up in PHP even though <code>error_reporting(E_ALL)</code> is set. I can't find a log of errors by using locate to find <code>error_log</code> or <code>php.err</code>, which I thought were the default names for the php error log.</li> </ul> <p>I feel like these two issues may be related, but I can't figure out why, maybe permissions? Something I noticed was that I cannot create or modify files in this directory without using the <code>sudo</code> command, which isn't usual.</p> <p>Another note: phpinfo() says nothing about cURL, but it works on the command line. I'm not sure why.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload