Unable to use PHP curl on amazon ec2 free tier

2019-07-25 07:59发布

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.

4条回答
疯言疯语
2楼-- · 2019-07-25 08:19

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.

查看更多
老娘就宠你
3楼-- · 2019-07-25 08:26

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! :)

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-07-25 08:27

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.

查看更多
Ridiculous、
5楼-- · 2019-07-25 08:40

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.

查看更多
登录 后发表回答