jerluc
jerluc

Reputation: 4316

php curl works from cli but not from apache

I can't get cURL to work from inside Apache by any means. It's actually fairly strange too provided that:

  1. I can execute my PHP pages from the CLI and it POSTs my requests perfectly fine
  2. When I look at my error logs, I get "PHP Fatal error: Call to undefined function curl_init()" as if the extension isn't installed at all. Similarly, a quick `phpinfo()` also yields such as if the extension isn't installed.

Additionally, when I built PHP, I opted the "--enable-curl" flag.

Upvotes: 3

Views: 1798

Answers (3)

Konrad Gałęzowski
Konrad Gałęzowski

Reputation: 1993

I had similar problem - worked from cli, silently failed from Apache 2.4

I've tried:

1) copying ssleay32.dll and libeay32.dll from php folder into apache\bin folder - didn't work

2) deleting ssleay32.dll and libeay32.dll from apache\bin folder completely - WORKED.

You should restart apache server each time you make change to make it work.

Also you should install both x86 and x64 versions of C++ Resistributable Visual Studio from Microsoft.

Upvotes: 0

lac.alan
lac.alan

Reputation: 291

I had same problem after installing php5-curl. I rebooted apache and that fixed it.

sudo /etc/init.d/apache2 restart for ubuntu 12.04

Upvotes: 0

bschaeffer
bschaeffer

Reputation: 2904

You are probably not loading the extension in the appropriate php.ini. The file should include something like:

[PHP_CURL]
extension=php_curl.dll

Also, --enable-curl is not a PHP configure option. --with-curl=[DIR] is the one you'd want. Check out the cURL installation instructions.

php_curl.dll should be inside PHP's ext directory when configured correctly.

Upvotes: 2

Related Questions