0

I have installed curl:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

and I have updated my php.ini file to include(I also tried .so):

extension=php_curl.dll

To test if curl is working I created a file called testCurl.php which contains the following:

<?php
echo ‘<pre>’;
var_dump(curl_version());
echo ‘</pre>’;
?>

When I navigate to localhost/testCurl.php I get an error: HTTP Error 500

Heres a snippet from the error log:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/php_curl.dll' - /usr/lib/php5/20090626+lfs/php_curl.dll: cannot op$

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open sha$

[Sun Dec 25 12:10:17 2011] [notice] Apache/2.2.20 (Ubuntu) PHP/5.3.6-13ubuntu3.3 with Suhosin-Patch configured -- resuming normal operations

[Sun Dec 25 12:13:46 2011] [error] [client 127.0.0.1] File does not exist: /var/www/css, referer: http://localhost/

[Sun Dec 25 12:13:46 2011] [error] [client 127.0.0.1] File does not exist: /var/www/css, referer: http://localhost/

[Sun Dec 25 12:13:46 2011] [error] [client 127.0.0.1] File does not exist: /var/www/css, referer: http://localhost/

[Sun Dec 25 12:13:46 2011] [error] [client 127.0.0.1] File does not exist: /var/www/css, referer: http://localhost/`

Can anyone help me to get curl working?

The problem was with the original test code. I used a new test file containing this and curl is now working:

<?php 
## Test if cURL is working ## 
## SCRIPT BY WWW.WEBUNE.COM (please do not remove)## 
echo '<pre>'; 
var_dump(curl_version()); 
echo '</pre>'; 
?>
  • 7
    .dll? are tou sure? try `curl.so` – Marcelo Bittencourt Dec 30 '11 at 03:47
  • I tried php_curl.so too but still no luck. localhost/testCurl.php gives me an HTTP 500 error... – Afsheen Khosravian Dec 30 '11 at 03:52
  • Many of the extensions enable themselves when installed. Try it without the line you added to php.ini and check for a curl.ini file in your php config directory. (And definitely not a .dll on Ubuntu) – cyberx86 Dec 30 '11 at 03:58
  • Thanks but still nothing.. There is a curl.ini in several locations: /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/cli/conf.d/curl.ini, /etc/php5/conf.d/curl.ini – Afsheen Khosravian Dec 30 '11 at 04:08
  • 2
    also, you need to restart the apache server after any changes in php.ini. – Marcelo Bittencourt Dec 30 '11 at 04:30
  • I did that too. Really strange its not working, right? haha Thanks a lot for your help though. This is driving me a bit crazy. – Afsheen Khosravian Dec 30 '11 at 04:39
  • What does the http server's error log tell? Did you try `curl.so` instead of `php_curl.so`? – tohuwawohu Dec 30 '11 at 15:10
  • I tired them both.. I edited my question with the error log. Thanks again. – Afsheen Khosravian Dec 30 '11 at 15:31
  • strange - there's no error regarding `curl.so` or `php_curl.so`. is this the complete error.log? how did you restart apache? did you try to restart apache with `force-reload`? – tohuwawohu Dec 30 '11 at 17:50
  • 1
    Did you check if the files are in /usr/lib/php5/20090626+lfs/ ? – Marcelo Bittencourt Dec 30 '11 at 18:18
  • This is how I am restarting apache: sudo /etc/init.d/apache2 reload. What I posted is not the complete error log. The complete error log is really long. I did not try force reload. The files being searched for are not in /usr/lib/php5/20090626+lfs/. – Afsheen Khosravian Dec 30 '11 at 20:28
  • I think the problem was with the test file I was using. I found the testCurl.php code online but I think there was a problem with it. I instead used a new test file and curl is working. I posted the new code to the question. – Afsheen Khosravian Dec 30 '11 at 23:50
  • Since you appear to have resolved your issue, please post it as an answer and accept it. That way the question doesn't keep coming back for new people to attempt to answer. – Michael Hampton Sep 20 '12 at 21:06

2 Answers2

2

When you install curl on a Ubuntu/Debian system, it is automatically loaded in your php installation with:

$ cat /etc/php5/conf.d/20-curl.ini
; configuration for php CURL module
; priority=20
extension=curl.so

You shouldn't do anything, apart restarting your webserver or cgi pool, e.g.:

sudo /etc/init.d/apache2 restart
sudo /etc/init.d/php-fpm restart
Giovanni Toraldo
  • 2,587
  • 19
  • 27
0

I'm not positive (I'm a SysAd who's been supporting PHP and RoR Devs) but I think that to use curl in PHP-land, I had to install a module using PECL.

I'm sorry that I don't have more details, but it was at least 6 months ago, and we'd since migrated to a different ticketing system.

gWaldo
  • 11,957
  • 8
  • 42
  • 69