1

I am currently moving my web app to amazon ec2. Since it's only for testing, I use the free version called ec2 free tier with windows server 2008 instance. However, Although I have done all I know and read this thread ( How to enable cURL in PHP / XAMPP ). I just couldn't use curl on my php script. it always creates the error Call to undefined function curl_init() in C:\xampp\htdocs\index.php on line 2 Here are all thing I have tried

  1. Install Wamp ( I tried it on XAMPP to)
  2. Uncomment out php_curl in php.ini file ( and restart apache)
  3. Copy two dll files to both system32 and syswow64

Could it have to do with the fact that I am using free vps? Update: Also, when I started the apache server in XAMPP , this error appeared 'PHP Startup: unable to load dynamic library curl.dll' However, I have double checked the ext directory and the php_curl.dll was in there.

Community
  • 1
  • 1
XabiAlonso
  • 17
  • 1
  • 4
  • What does phpinfo() tell you about curl? – Mark Jul 22 '12 at 08:58
  • I'm not sure what you mean by `Comment out php_curl` but you shouldn't comment out that line, you should uncomment, **remove** the semicolon before it. – Adi Jul 22 '12 at 08:59
  • @Mark: I use Ctrl+F with keywork 'curl' on phpinfo() page but nothing is found. – XabiAlonso Jul 22 '12 at 09:20
  • Yeah sounds like a problem with the .dll file or something. Have you tried this: http://www.digizol.org/2008/10/phpcurldll-unable-load-dynamic-library.html – Mark Jul 22 '12 at 12:45
  • Correcting above link: http://www.digizol.com/2008/10/phpcurldll-unable-load-dynamic-library.html – lkamal Nov 03 '13 at 08:33

4 Answers4

1

i think curl need to access remote sever from our web server. so i opened all traffic in my server outbound rule and it works. i think this is not good solution. still look for better way.

Do Hoa Vinh
  • 356
  • 4
  • 11
0

nope.

be sure, that you have the files in the right place, usually its in the plugins folder for php! maybe you cann add a absolute path to your php.ini! be sure, you edit the correct ini file!

php completly independent to your operatingsystem!

just be sure to doublecheck everything. because its not saying, it has trouble loading your extention, its just saying, the function your trying to call, is not there. so i assume your extention ist not loading at all! :)

easteregg
  • 509
  • 4
  • 9
  • Since I use WAMP, I think the php.ini and the dll are properly configured. Also, Don't know why it works on my machine but not on amz vps. – XabiAlonso Jul 22 '12 at 09:17
0

One reason I did notice for this cURL plugin to malfunction was the availability of copies of libeay32.dll and ssleay32.dll files. Please check whether your system32 folder has such copies and if so, please rename them to some other names and copy the ones found with the php installation. Sometimes you may need to restart your machine. This was documented here some time ago.

lkamal
  • 3,788
  • 1
  • 20
  • 34
0

I had a similar problem, but it occours just with requests under https. I tried to create a curl request directly from the ec2 machine and got a error: "curl: (77) error setting certificate verify locations".

It looks like some kind of ssl validation fail because of a certificate not found. So I used a parameter -k (or --insicure) in my curl command, to ignore this validation and after that my curls request did directly from ec2 machine worked.

So I tried to apply a similar ideia in my curl command in php, (I suppoused that the curl php extension forward this requests to the operation system) and I found this curl opt:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

After that it works to me.

Probably this isn't the best way to solve the problem, but solved my problem temporarelly.